I am a bit of a newbie as far as dealing with compilation/linking errors.
I'm working with a large C++ code (there are a few C files as well). I have successfully been running 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 that uses the libraries.
I can compile all of the code on the cluster using the default g++ compiler. However, unfortunately, I have discovered that I need to compile with gcc/4.7.2 so that the code will work with other software on the cluster. I have been working my way through compilation and linking errors. So far, they have all been related to issues with C++ versus C. For example, I have had to add "extern" in some of the C files. I have had to change includes from C++ to C headers.
My problem seems to be with one particular library (I have successfully dealt with all the others). It compiles in its directory. But when I go to my run directory, I get all kinds of errors that seem to be related to the code that makes up this problem library. My guess is that they are mostly related to not finding the standard libraries. I just don't understand how there is a problem with my includes and 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 there does seem to be a lot of C-style code in its files.
There are far too many errors (pages) and far too much code to post everything. I hope that what I have posted is sufficient and can add to it if that would help. I can't locate exactly where they are coming from in my code because they are very cryptic; for example:
Code.cpp:(.text+0x35): undefined reference to `std::cout'
My makefile include and compiler options are below. I originally created this on my Mac using QT. I modified it to work with the Linux cluster on gcc/4.7.2. So it is entirely possible that it is a bit of a mess.
First I do (command line in terminal):
module load gcc/4.7.2
Then the makefile is:
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: .o .c .cpp .cc .cxx .C
.cpp.o: $(CC) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
.cc.o: $(CC) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
.cxx.o: $(CC) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
.C.o: $(CC) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
.c.o: $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
Now the kinds of errors I'm getting:
Code.o: In function
_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.part.8':
Code.cpp:(.text+0x12): undefined reference to
std::basic_ios >::clear(std::_Ios_Iostate)' Code.o: In
function
_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.constprop.101':
Code.cpp:(.text+0x35): undefined reference to
std::cout'
Code.cpp:(.text+0x3a): undefined reference to
`std::basic_ostream >&
std::__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 reference to std::cout' Code.o: In
function
_ZNSt14basic_ofstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode.constprop.99':
Code.cpp:(.text+0x93): undefined reference to
std::basic_filebuf<char, std::char_traits<char> >::open(char const*,
std::_Ios_Openmode)' Code.o: In function
_ZNSt18basic_stringstreamIcSt11char_traitsIcESaIcEEC1ESt13_Ios_Openmode.constprop.96':
Code.cpp:(.text+0x103): 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 reference 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_iostream()'
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 on:
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 function Other::free_internal()': gl3.cpp:(.text+0x251): undefined reference to
operator delete' gl3.cpp:(.text+0x262): ...
Does any of this mean anything to anyone?