链接错误stdc ++

时间:2016-03-11 09:11:21

标签: c++ linux ffmpeg

为什么我会遇到这些链接错误?

以下是链接错误的简短示例,有数百种类似的:

  

/tmp/main-NtNkRQ.o:在函数__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):   对std::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:   对__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:   未定义引用__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):   对vtable 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:   在函数GO_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:   在函数~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:   在函数GO_C_Align::de_init()': /home/go/NetBeansProjects/Arbete_216/Ajourwork/Utilities/Image/Align/GO_C_Align.cpp:187: undefined reference to中删除运算符'   /home/go/NetBeansProjects/Arbete_216/Ajourwork/Components/TheRealDeal/GUI/linuxobj//GO_C_Align.o:   在函数GO_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)'

我在Debian 7上,使用Clang编译器。代码使用makefile系统构建,使用以下编译器标志

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

如果我将-lstdc ++添加到我的编译器选项中,FFmpeg会提供链接错误。正如我在本网站的其他地方看到的那样,我已将FFmpeg包含在extern“C”中。它没有帮助。但我认为这不是问题所在。

FFmpeg从源代码编译为动态库。 (当我链接静态库时,我有相同的行为。)

我已经使用ldd检查了FFmpeg库,并且依赖项已经到位。我已经检查了32/64混音,但它似乎都应该是64。

root @ antec:/ usr / local / lib#file libavcodec.so.57.27.101 libavcodec.so.57.27.101:ELF 64位LSB共享对象,x86-64,版本1(SYSV),动态链接,BuildID [sha1] = 0x6bf103d9a0531802fdcc608a8032a77d5b89b898,剥离 root @ antec:/ usr / local / lib #file /lib/x86_64-linux-gnu/libc.so.6 /lib/x86_64-linux-gnu/libc.so.6:指向`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位LSB的共享对象,X86-64,版本1(SYSV),动态链接(使用共享库),BuildID [SHA1] = 0xb5053aa2420700afc9687ab357a8d5d89fcb1bd0用于GNU / Linux 2.6.26,剥离

FFmpeg源代码中包含的示例已编译并链接正常。

是否有任何其他外部部件可以提供这些错误? C ++ 11?任何迹象都有帮助。感谢。

2 个答案:

答案 0 :(得分:1)

您可能使用clang作为变量CXX的值。相反,您应该使用clang++,因为clang前端不会隐式链接到C ++标准库。

答案 1 :(得分:0)

也许您应该将.so或.a的路径添加到项目中,而不是仅将其复制到项目文件夹中。