Reputation: 95
Why am I having these linking errors?
Here is a short sample of link errors, there are hundreds similar:
/tmp/main-NtNkRQ.o: In function
__cxx_global_var_init': /home/go/NetBeansProjects/Arbete_216/Ajourwork/Components/TheRealDeal/GUI/../../../Components/TheRealDeal/GUI/main.cpp:(.text+0x10): undefined reference to
std::ios_base::Init::Init()' /home/go/NetBeansProjects/Arbete_216/Ajourwork/Components/TheRealDeal/GUI/../../../Components/TheRealDeal/GUI/main.cpp:(.text+0x17): undefined reference tostd::ios_base::Init::~Init()' /tmp/main-NtNkRQ.o: In function
main': /home/go/NetBeansProjects/Arbete_216/Ajourwork/Components/TheRealDeal/GUI/../../../Components/TheRealDeal/GUI/main.cpp:123: undefined reference to__cxa_begin_catch' /home/go/NetBeansProjects/Arbete_216/Ajourwork/Components/TheRealDeal/GUI/../../../Components/TheRealDeal/GUI/main.cpp:127: undefined reference to
__cxa_end_catch' /home/go/NetBeansProjects/Arbete_216/Ajourwork/Components/TheRealDeal/GUI/../../../Components/TheRealDeal/GUI/main.cpp:127: undefined reference to__cxa_end_catch' /home/go/NetBeansProjects/Arbete_216/Ajourwork/Components/TheRealDeal/GUI/../../../Components/TheRealDeal/GUI/main.cpp:123: undefined reference to
std::terminate()' /tmp/main-NtNkRQ.o:(.data.rel.ro._ZTI26go_s_module_init_exception[_ZTI26go_s_module_init_exception]+0x0): undefined reference tovtable for __cxxabiv1::__class_type_info' /tmp/main-NtNkRQ.o:(.data.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): undefined reference to
__gxx_personality_v0' /home/go/NetBeansProjects/Arbete_216/Ajourwork/Components/TheRealDeal/GUI/linuxobj//GO_C_Align.o: In functionGO_C_Align': /home/go/NetBeansProjects/Arbete_216/Ajourwork/Utilities/Image/Align/GO_C_Align.cpp:35: undefined reference to
std::terminate()' /home/go/NetBeansProjects/Arbete_216/Ajourwork/Components/TheRealDeal/GUI/linuxobj//GO_C_Align.o: In function~GO_C_Align': /home/go/NetBeansProjects/Arbete_216/Ajourwork/Utilities/Image/Align/GO_C_Align.cpp:44: undefined reference to
std::terminate()' /home/go/NetBeansProjects/Arbete_216/Ajourwork/Components/TheRealDeal/GUI/linuxobj//GO_C_Align.o: In functionGO_C_Align::de_init()': /home/go/NetBeansProjects/Arbete_216/Ajourwork/Utilities/Image/Align/GO_C_Align.cpp:187: undefined reference to
operator delete' /home/go/NetBeansProjects/Arbete_216/Ajourwork/Components/TheRealDeal/GUI/linuxobj//GO_C_Align.o: In functionGO_C_Align::init(int, int, GO_C_BufferManager*)': /home/go/NetBeansProjects/Arbete_216/Ajourwork/Utilities/Image/Align/GO_C_Align.cpp:121: undefined reference to
operator new[](unsigned long)'
I am on Debian 7, using Clang compiler. The code is built using a makefile system, the following compiler flags is used
CXXFLAGS = -g -I /opt/intel/composer_xe_2015.1.133/ipp/include/ -Wno-deprecated -D_GNU_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -I/usr/include/postgresql/ -I/usr/local/Qt/5.2.1/gcc_64/include/QtX11Extras/ -I/usr/local/Qt/5.2.1/gcc_64/include/QtWidgets/ -I/usr/local/Qt/5.2.1/gcc_64/include/ -I/usr/local/Qt/5.2.1/gcc_64/include/QtGui/ -fPIC -fPIE -I/home/go/ffmpeg_build/include/ -I/usr/local/Qt/5.2.1/gcc_64/include/QtCore/ -fPIC -fPIE -I/home/go/ffmpeg_build/include/libavcodec -I/home/go/ffmpeg_build/include/libavformat/
$(CXX) -o xxx_GUI $(MAIN_FILE) $(TARGETROOT)/*.o $(TARGETROOT)/*.a $(DEFINE_FLAGS) $(INCLUDE_FLAGS) $(CXXFLAGS) -lpq -lippi -lipps -lippcore -lpthread -lgcrypt -lippvm -lippcv -lippcc -L/opt/intel/composer_xe_2015.1.133/ipp/lib/intel64 -L/usr/local/Qt/5.2.1/gcc_64/include/QtWidgets/ -L/usr/X11R6/lib/ -lXv -lX11 -lXext -ltar
If I add -lstdc++ to my compiler options, FFmpeg gives link errors instead. I have wrapped FFmpeg includes in extern "C" as I have seen elsewhere on this site. It doesn't help. But I don't think that is the problem here.
FFmpeg is compiled as dynamic libs from source. (I had the same behavior when I linked static libs.)
I have checked the FFmpeg libs with ldd and the dependencies is in place. I have checked for 32/64 mix-ups but it all seems to be 64 as it should be.
root@antec:/usr/local/lib# file libavcodec.so.57.27.101 libavcodec.so.57.27.101: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=0x6bf103d9a0531802fdcc608a8032a77d5b89b898, stripped root@antec:/usr/local/lib# file /lib/x86_64-linux-gnu/libc.so.6 /lib/x86_64-linux-gnu/libc.so.6: symbolic link to `libc-2.13.so' root@antec:/usr/local/lib# file /lib/x86_64-linux-gnu/libc-2.13.so /lib/x86_64-linux-gnu/libc-2.13.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), BuildID[sha1]=0xb5053aa2420700afc9687ab357a8d5d89fcb1bd0, for GNU/Linux 2.6.26, stripped
The example contained in FFmpeg source compiled and linked fine.
Is there any other external part that could give these errors? C++11? Any indication could help. Thanks.
Upvotes: 1
Views: 1825
Reputation: 17920
You're probably using clang
as the value of variable CXX
. Instead you should use clang++
, because the clang
frontend does not implicitly link with the C++ standard libraries.
Upvotes: 2
Reputation: 15
maybe you should add the path of .so or .a to your project instead of just copying it into your project folders.
Upvotes: 0