c++ - Makefile error :make: *** [main] Error 1 -
i executing makefile 3 parts project overloading opertions big numbers: bignum.h
#include <vector> #ifndef bignum_h #define bignum_h class impossible_number_exception{}; class bignum{ public: //some functions private:    // }; #endif   the second part bignum.cpp include libraries , functions , third part main.cpp write testing library:
int main(){ bignum f("8913.67811"); bignum r(-5453.578); d=-1.02+f; if(d>r){ cout<<f<<endl; } cout<<d[3]; return 0; }   and makefile this:
all:main.o bignum.o    g++ -o a.out bignum.o main.o:main.cpp bignum.o    g++ -c main.cpp bignum.o:bignum.h bignum.cpp    g++ -c bignum.cpp clean:    rm -rf*.o   and place tabs , spaces correctly got error of line is:
g++ -c main.cpp cc   main.o   -o main main.o: in function `main': main.cpp:(.text+0x23): undefined reference   std::allocator<char>::allocator() ... main.cpp:(.text+0xb6): undefined reference `bignum::bignum(double)' main.cpp:(.text+0x2d9): undefined reference `std::ios_base::init::~init()' main.o:(.eh_frame+0x13): undefined reference `__gxx_personality_v0' collect2: error: ld returned 1 exit status <builtin>: recipe target 'main' failed make: *** [main] error 1   what should this?
well change makefile this
cxx=g++ cxxflags=-g main: main.o bignum.o $(cxx) $(cxxflags) -o main main.o bignum.o main.o: main.cpp bignum.h $(cxx) $(cxxflags) -c main.cpp bignum.o:bignum.cpp bignum.h $(cxx) $(cxxflags) -c bignum.cpp   and works!!!!!!!! can not found out problem of first makefile!
Comments
Post a Comment