I've got an issue where CMake can't detect pthread. As a work-around I tried:
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lpthread")
However, this inserts -lpthread
in the wrong place:
/usr/bin/c++ -std=c++11 -D_GNU_SOURCE -Wall [manyflags ...] -lpthread \
CMakeFiles/connectivity_tool.dir/connectivity_tool/conn_tool.cpp.o \
-o connectivity_tool -rdynamic -lboost_system [many libraries...]
This results in:
/usr/bin/ld: /tmp/ccNvRifh.ltrans3.ltrans.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
Of course, the -lpthread
should be at the end of the 3rd line, not the end of the 1st.
How can I go about either getting CMake to add -lpthread
at the end of this line, or perhaps even modifying the generated Makefiles somehow in some hacky way to get this to work?
(If the answer involves actually detecting pthread properly then answer the linked question.)