I am writng in relation to a problem I have, when trying to compile a c++ source with a makefile.
The code has only one peculiarity that it contains a FORTRAN subroutine. This is not an issue because I can link and compile it without problems when I use the command line. I first create an object from the FORTRAN subroutine and then can link it without any problems. However if I try to do the same with my make file, I gate an linking error. My guess is that I have something wrong in the make file.
The first thing I did is to use the –MM option of g++ to generate the dependencies, for compiling i use intel compilers:
When I run this I get the following linking errors:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
a.o: In function `A::~A()':
a.cpp:(.text+0x42): undefined reference to `std::cout'
a.cpp:(.text+0x4c): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, charconst*)'
a.cpp:(.text+0x54): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
a.cpp:(.text+0x59): undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
a.o: In function `A::~A()':
a.cpp:(.text+0x62): undefined reference to `std::cout'
a.cpp:(.text+0x6c): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
a.cpp:(.text+0x74): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
a.cpp:(.text+0x79): undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
a.o: In function `__sti__$E':
a.cpp:(.text+0x97): undefined reference to `std::ios_base::Init::Init()'
a.cpp:(.text+0x9c): undefined reference to `std::ios_base::Init::~Init()'
a.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
make: *** [MAZ] Fehler 1
I am trying to learn the whole issue with the make files and would appreciate if the knowledgeable people on this forum can provide me with assistance.
Thanks
Wronski
icc -o MM a.o f.o b.o fortm.o matt.o main.cpp
icc -o MM a.o f.o b.o fortm.o matt.o main.o
should be equivalent.
`Everyting crashes' is not a meaningful message, I don't understand why you blame the makefile when the error also occurs with the command line.
If i change $< with $^ I get more error messages than before.
¿Do they say the same? If your code fails to build, maybe the problem is with your code.
Also, please note that the tags don't wrap text, so fmt the messages or don't use tags
The problem comes in my opinion on the linking stage. Concerning the loose statement ‘Everything crashes’ – well I get more than 250 lines of error messages. The problem is that this project will grow in its files numbers, and I would like to learn what am I doing wrong?