0

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?

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

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) 

1 Comment

You'd think find_package(Threads) would sort this out, but if it detects pthread it decides it should be blank instead.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.