简体   繁体   中英

Error during make: error adding symbols: DSO missing from command line

I am trying to compile some code downloaded from a git repository (OpenNI2, https://github.com/occipital/OpenNI2 ). I am getting the following errors after running make:

make -C Source/Tools/NiViewer
make[1]: Entering directory `/home/karnivaurus/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/karnivaurus/Data/Libraries/OpenNI2/Source/Tools/NiViewer'
make: *** [Source/Tools/NiViewer] Error 2

Any ideas on how I should go about solving this?

You have to add the directive "-lpthread" to your compiler and it is solved.

for instance if your previous code was: g++ mycode.cpp -o myexecutable

Now you have to put g++ mycode.cpp -lpthread -o myexecutable

You need add the pthread library into the target_link_libraries. You can edit your CMakeLists.txt file as follow. This solution works for me.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM