make期间出错:添加符号时出错:命令行中缺少DSO

时间:2014-10-23 10:54:57

标签: c++ linux makefile

我正在尝试编译从git存储库下载的一些代码(OpenNI2,https://github.com/occipital/OpenNI2)。运行make后我收到以下错误:

make -C Source/Tools/NiViewer
make[1]: Entering directory `/home/ejohns/Data/Libraries/OpenNI2/Source/Tools/NiViewer'
g++ -o ../../../Bin/x64-Release/NiViewer ./../../../Bin/Intermediate/x64-Release/NiViewer/Device.o ./../../../Bin/Intermediate/x64-Release/NiViewer/Draw.o ./../../../Bin/Intermediate/x64-Release/NiViewer/Keyboard.o ./../../../Bin/Intermediate/x64-Release/NiViewer/Menu.o ./../../../Bin/Intermediate/x64-Release/NiViewer/MouseInput.o ./../../../Bin/Intermediate/x64-Release/NiViewer/NiViewer.o ./../../../Bin/Intermediate/x64-Release/NiViewer/Capture.o -L../../../ThirdParty/PSCommon/XnLib/Bin/x64-Release -L../../../Bin/x64-Release -lglut -lGL -lOpenNI2 -lXnLib -Wl,-rpath ./
/usr/bin/ld: ../../../ThirdParty/PSCommon/XnLib/Bin/x64-Release/libXnLib.a(XnLinuxMutex.o): undefined reference to symbol 'pthread_mutexattr_settype@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[1]: *** [../../../Bin/x64-Release/NiViewer] Error 1
make[1]: Leaving directory `/home/ejohns/Data/Libraries/OpenNI2/Source/Tools/NiViewer'
make: *** [Source/Tools/NiViewer] Error 2

关于如何解决这个问题的任何想法?

2 个答案:

答案 0 :(得分:1)

你必须添加指令" -lpthread"到你的编译器,它就解决了。

例如,如果您之前的代码是: g ++ mycode.cpp -o myexecutable

现在你必须把 g ++ mycode.cpp -lpthread -o myexecutable

答案 1 :(得分:0)

您需要将pthread库添加到target_link_libraries中。您可以编辑CMakeLists.txt文件,如下所示。这个解决方案适合我。

    target_link_libraries(ExcutableFileName ${Existed_LIBRARY})
    -->
    target_link_libraries(ExcutableFileName ${Existed_LIBRARY} pthread)