whoenig/NatNetSDKCrossplatform

make error

lkyfly0765 opened this issue · 2 comments

I cannot complie this program:
Why there occurs undefined reference to pthread_condattr_setclock` ?
Thanks!

eric@eric-ThinkPad-S2:/NatNetSDKCrossplatform/build$ cmake ..
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Boost 1.70.0 at /usr/local/lib/cmake/Boost-1.70.0
-- Requested configuration: QUIET REQUIRED COMPONENTS system;thread
-- Found boost_headers 1.70.0 at /usr/local/lib/cmake/boost_headers-1.70.0
-- Found boost_system 1.70.0 at /usr/local/lib/cmake/boost_system-1.70.0
-- libboost_system.a
-- Adding boost_system dependencies: headers
-- Found boost_thread 1.70.0 at /usr/local/lib/cmake/boost_thread-1.70.0
-- libboost_thread.a
-- Adding boost_thread dependencies: headers
Boost 1.65 found.
Found Boost components:
system;thread
-- Configuring done
-- Generating done
-- Build files have been written to: /home/eric/NatNetSDKCrossplatform/build
eric@eric-ThinkPad-S2:
/NatNetSDKCrossplatform/build$ make
Scanning dependencies of target mcr
[ 20%] Building CXX object CMakeFiles/mcr.dir/src/multicast_receiver.cpp.o
/home/eric/NatNetSDKCrossplatform/src/multicast_receiver.cpp:18:37: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
constexpr char* MULTICAST_ADDRESS = "239.255.42.99";
^
/home/eric/NatNetSDKCrossplatform/src/multicast_receiver.cpp:58:58: warning: unused parameter ‘length’ [-Wunused-parameter]
[this](boost::system::error_code ec, std::size_t length)
^
/home/eric/NatNetSDKCrossplatform/src/multicast_receiver.cpp: In function ‘int main(int, char**)’:
/home/eric/NatNetSDKCrossplatform/src/multicast_receiver.cpp:101:12: warning: unused variable ‘reply_length’ [-Wunused-variable]
size_t reply_length = socket_cmd.receive_from(
^
[ 40%] Building CXX object CMakeFiles/mcr.dir/src/PacketClientHelper.cpp.o
/home/eric/NatNetSDKCrossplatform/src/PacketClientHelper.cpp:163:33: warning: unused parameter ‘destsz’ [-Wunused-parameter]
int strcpy_s(char* dest, size_t destsz, const char src)
^
/home/eric/NatNetSDKCrossplatform/src/PacketClientHelper.cpp: In function ‘void Unpack(char
)’:
/home/eric/NatNetSDKCrossplatform/src/PacketClientHelper.cpp:326:22: warning: unused variable ‘bTrackingValid’ [-Wunused-variable]
bool bTrackingValid = params & 0x01; // 0x01 : rigid body was s
^
/home/eric/NatNetSDKCrossplatform/src/PacketClientHelper.cpp:379:30: warning: unused variable ‘bTrackingValid’ [-Wunused-variable]
bool bTrackingValid = params & 0x01; // 0x01 : rigid bo
^
/home/eric/NatNetSDKCrossplatform/src/PacketClientHelper.cpp:432:30: warning: unused variable ‘bHasModel’ [-Wunused-variable]
bool bHasModel = (params & 0x08) != 0; // marker ha
^
/home/eric/NatNetSDKCrossplatform/src/PacketClientHelper.cpp:433:30: warning: unused variable ‘bUnlabeled’ [-Wunused-variable]
bool bUnlabeled = (params & 0x10) != 0; // marker is
^
/home/eric/NatNetSDKCrossplatform/src/PacketClientHelper.cpp:434:30: warning: unused variable ‘bActiveMarker’ [-Wunused-variable]
bool bActiveMarker = (params & 0x20) != 0; // marker is
^
/home/eric/NatNetSDKCrossplatform/src/PacketClientHelper.cpp:427:26: warning: unused variable ‘bOccluded’ [-Wunused-variable]
bool bOccluded = (params & 0x01) != 0; // marker was no
^
/home/eric/NatNetSDKCrossplatform/src/PacketClientHelper.cpp:428:26: warning: unused variable ‘bPCSolved’ [-Wunused-variable]
bool bPCSolved = (params & 0x02) != 0; // position prov
^
/home/eric/NatNetSDKCrossplatform/src/PacketClientHelper.cpp:429:26: warning: unused variable ‘bModelSolved’ [-Wunused-variable]
bool bModelSolved = (params & 0x04) != 0; // position prov
^
/home/eric/NatNetSDKCrossplatform/src/PacketClientHelper.cpp:559:14: warning: unused variable ‘bIsRecording’ [-Wunused-variable]
bool bIsRecording = (params & 0x01) != 0; // 0x01 Moti
^
/home/eric/NatNetSDKCrossplatform/src/PacketClientHelper.cpp:560:14: warning: unused variable ‘bTrackedModelsChanged’ [-Wunused-variable]
bool bTrackedModelsChanged = (params & 0x02) != 0; // 0x02 Acti
^
/home/eric/NatNetSDKCrossplatform/src/PacketClientHelper.cpp:579:42: warning: too many arguments for format [-Wformat-extra-args]
printf("Type : %d\n", i, type);
^
/home/eric/NatNetSDKCrossplatform/src/PacketClientHelper.cpp: In instantiation of ‘int sprintf_s(char*, size_t, const char*, Args ...) [with Args = {int, int, int, int, int}; size_t = long unsigned int]’:
/home/eric/NatNetSDKCrossplatform/src/PacketClientHelper.cpp:196:88: required from here
/home/eric/NatNetSDKCrossplatform/src/PacketClientHelper.cpp:169:64: warning: unused parameter ‘bufsz’ [-Wunused-parameter]
template<typename... Args> int sprintf_s(char * buffer, size_t bufsz, const cha
^
[ 60%] Linking CXX executable mcr
CMakeFiles/mcr.dir/src/multicast_receiver.cpp.o: In function boost::asio::detail::posix_event::posix_event()': multicast_receiver.cpp:(.text._ZN5boost4asio6detail11posix_eventC2Ev[_ZN5boost4asio6detail11posix_eventC5Ev]+0x4d): undefined reference to pthread_condattr_setclock'
CMakeFiles/mcr.dir/src/multicast_receiver.cpp.o: In function boost::asio::detail::posix_thread::~posix_thread()': multicast_receiver.cpp:(.text._ZN5boost4asio6detail12posix_threadD2Ev[_ZN5boost4asio6detail12posix_threadD5Ev]+0x26): undefined reference to pthread_detach'
CMakeFiles/mcr.dir/src/multicast_receiver.cpp.o: In function boost::asio::detail::posix_thread::join()': multicast_receiver.cpp:(.text._ZN5boost4asio6detail12posix_thread4joinEv[_ZN5boost4asio6detail12posix_thread4joinEv]+0x2b): undefined reference to pthread_join'
CMakeFiles/mcr.dir/src/multicast_receiver.cpp.o: In function boost::asio::detail::posix_thread::start_thread(boost::asio::detail::posix_thread::func_base*)': multicast_receiver.cpp:(.text._ZN5boost4asio6detail12posix_thread12start_threadEPNS2_9func_baseE[_ZN5boost4asio6detail12posix_thread12start_threadEPNS2_9func_baseE]+0x38): undefined reference to pthread_create'
CMakeFiles/mcr.dir/src/multicast_receiver.cpp.o: In function boost::asio::detail::posix_signal_blocker::posix_signal_blocker()': multicast_receiver.cpp:(.text._ZN5boost4asio6detail20posix_signal_blockerC2Ev[_ZN5boost4asio6detail20posix_signal_blockerC5Ev]+0x64): undefined reference to pthread_sigmask'
CMakeFiles/mcr.dir/src/multicast_receiver.cpp.o: In function boost::asio::detail::posix_signal_blocker::~posix_signal_blocker()': multicast_receiver.cpp:(.text._ZN5boost4asio6detail20posix_signal_blockerD2Ev[_ZN5boost4asio6detail20posix_signal_blockerD5Ev]+0x2d): undefined reference to pthread_sigmask'
collect2: error: ld returned 1 exit status
CMakeFiles/mcr.dir/build.make:120: recipe for target 'mcr' failed
make[2]: *** [mcr] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/mcr.dir/all' failed
make[1]: *** [CMakeFiles/mcr.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

I have solved it.
It just because the cmake version is not compatible with the boost version.
Just add set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") in Cmakelist.txt, and it will be ok.

For Ubuntu 16.04 users, the boost version is not compatible with this repo. You can change the boost version in cmakelists.txt to 1.58 and re-make it again.