I'm a little new to compilation / linking errors.
I work with large C ++ code (there are also several C files). I successfully run it on a Mac compiled with g ++. Now I need to run it on a Linux-based cluster, because it is too slow on my Mac. The code consists of several libraries that I have to compile, plus my own code, which uses libraries.
I can compile all the code in the cluster using the default g ++ compiler. However, unfortunately, I found that I need to compile gcc / 4.7.2 for the code to work with other cluster software. I am working on creating compilation and linking errors. So far, they have all been related to problems with C ++ compared to C. For example, I had to add "extern" to some of the C files. I had to make changes from C ++ to the C headers.
My problem seems to be related to one particular library (I have successfully dealt with all the others). It compiles in its directory. But when I go to my startup directory, I get all kinds of errors that seem to be related to the code that makes up this problem library. I assume that they are mainly related to the fact that standard libraries are not found. I just donβt understand how the problem arises with my inclusions, and I would really appreciate it if someone could take a look at what I have in my makefile for this library. This library is officially based on "C ++", but its files seem to have a lot of C-style code.
Too many errors (pages) and too much code to publish everything. I hope that what I posted is sufficient and can add to it if that helps. I canβt determine exactly where they come from in my code, because they are very mysterious; eg:
Code.cpp :(. Text + 0x35): undefined reference to `std :: cout '
My makefile options and compiler options are below. I originally created this on my Mac using QT. I changed it to work with a Linux cluster on gcc / 4.7.2. Therefore, it is possible that this is a bit of a mess.
First I do (command in terminal):
Download gcc / 4.7.2 module
Then makefile:
CC = gcc
DEFINES = -DIPMGEMPLUGIN -DNOPARTICLEARRAY -D__unix
CFLAGS = -c -g -O2 -pedantic -fno-nonansi-builtins -D__unix -m64
CXXFLAGS = -pipe -O2 -Wall -W -fPIC $ (DEFINES) -lstdC ++ -m64
INCPATH = -I. \
-I/mounts/apps/gcc/4.7.2/ \ -I/mounts/apps/gcc/4.7.2/bin/ \ -I/mounts/apps/gcc/4.7.2/bin/x86_64-unknown-linux-gnu/4.7.2 \ -I/mounts/apps/gcc/4.7.2/lib64 \ -I/mounts/apps/gcc/4.7.2/bin/include \ -I/mounts/apps/gcc/4.7.2/bin/include/c++ \ -I/mounts/apps/gcc/4.7.2/4.7.2/bin/include/c++/4.7.2 \
AR = ar cq RANLIB = ranlib -s TARGET = mylib.a
.SUFFIXES: .occpp.cc.cxx.C
.cpp.o: $ (CC) -c $ (CXXFLAGS) $ (INCPATH) -o "$ @" "$ <"
.cc.o: $ (CC) -c $ (CXXFLAGS) $ (INCPATH) -o "$ @" "$ <"
.cxx.o: $ (CC) -c $ (CXXFLAGS) $ (INCPATH) -o "$ @" "$ <"
.Co: $ (CC) -c $ (CXXFLAGS) $ (INCPATH) -o "$ @" "$ <"
.co: $ (CC) -c $ (CFLAGS) $ (INCPATH) -o "$ @" "$ <"
Now the types of errors that I get:
Code.o: In the function _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.part.8': Code.cpp:(.text+0x12): undefined reference to std :: basic_ios> clear _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.constprop.101': Code.cpp:(.text+0x35): undefined reference to standard :: soy "Code.cpp :(. Text + 0x3a): undefined reference to` std :: basic_ostream> & stand :: __ ostream_insert
(std :: basic_ostream> &, char const *, long) 'Code.cpp :(. text + 0x3f): undefined reference to std::cout' Code.cpp:(.text+0x49): undefined reference to std: : cout 'Code.cpp :(. Text + 0x53): undefined link to std::cout' Code.o: In function _ZNSt14basic_ofstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode.constprop.99 ': Code.cpp :(. Text + 0x93 )d undefined std::basic_filebuf<char, std::char_traits<char> >::open(char const*, std::_Ios_Openmode)' Code.o: In function basic_filebuf ): undefined reference to std::ios_base::ios_base()' Code.cpp:(.text+0x10b): undefined reference to vtable for std :: basic_ios' Code.cpp :(. Text + 0x11b): undefined link to VTT for std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >' Code.cpp:(.text+0x15d): undefined reference to std :: basic_iostream> :: basic_ios tream () 'Code.cpp :(. Text + 0x16c): undefined reference to vtable for std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >' Code.cpp:(.text+0x174): undefined reference to vtable for std :: basic_stringstream, std :: allocator> 'Code.cpp :(. text + 0x17c): undefined reference to vtable for std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >' Code.cpp:(.text+0x184): undefined reference to vtable for std :: basic_streambuf> '
And further:
gl3.cpp :(. text + 0x18d): undefined reference to `operator new [] (unsigned long) '
gl3.cpp :(. text + 0x1a1): undefined reference to `operator new [] (unsigned long) '
gl3.cpp :(. text + 0x1b5): undefined reference to `operator new [] (unsigned long) '
gl3.cpp :(. text + 0x1c9): undefined reference to `operator new [] (unsigned long) '
gl3.cpp :(. text + 0x1dd): undefined reference to `operator new [] (unsigned long) '
/data/place/number/account/CodeDirectory/../ProblemLibraryDirectory/libProblem.a(gl3.o): In the function Other::free_internal()': gl3.cpp:(.text+0x251): undefined reference to statement delete 'gl3.cpp :(. Text + 0x262): ...
Does this mean anything to someone?