Hey there, I am creating my own package with Boost, and I have a .cpp file that is able to compile using g++ with:

g++ newboost.cpp -o boost -lboost_system -lpthread


But, when I try to put the .cpp file into my package and catkin_make my package, I get the following error:

/usr/bin/ld: CMakeFiles/keyencelaser_node.dir/src/newboost.cpp.o: undefined reference to symbol 'pthread_create@@GLIBC_2.2.5'
collect2: error: ld returned 1 exit status
keyencelaser/CMakeFiles/keyencelaser_node.dir/build.make:95: recipe for target '/home/ateator/catkin_ws/devel/lib/keyencelaser/keyencelaser_node' failed
make[2]: *** [/home/ateator/catkin_ws/devel/lib/keyencelaser/keyencelaser_node] Error 1
CMakeFiles/Makefile2:4463: recipe for target 'keyencelaser/CMakeFiles/keyencelaser_node.dir/all' failed
make[1]: *** [keyencelaser/CMakeFiles/keyencelaser_node.dir/all] Error 2
Makefile:138: recipe for target 'all' failed


which is a similar error to the one I got before adding the flags onto the g++ terminal command

I have tried to add Boost into my CMakeLists.txt, but (although it did improve my errors), I am still left with the above errors. My CMakeLists.txt is:

find_package(catkin REQUIRED COMPONENTS
roscpp

)
find_package(
Boost
)
include_directories(
${catkin_INCLUDE_DIRS} ) add_executable(keyencelaser_node src/newboost.cpp) target_link_libraries(keyencelaser_node${Boost_FILESYSTEM_LIBRARIES}
${Boost_SYSTEM_LIBRARY} )  I am pretty sure it's a linker error but I don't know how to fix it. Again, the edits I made to my CMakeLists.txt eliminated a lot of "undefined reference to" errors, but now that those are gone, I am left with the above. I appreciate any and all help. Thank you. edit retag close merge delete ## Comments just tried adding set (CMAKE_CXX_FLAGS "-lboost_system") and set(CMAKE_CXX_FLAGS "-lpthread") to my CMakeLists, but the error remains the same ( 2016-12-21 08:52:05 -0500 )edit Not an answer, but seeing the references to Keyence & lasers: have you seen ros-industrial/keyence_experimental? Needs some work, but might be interesting / save you some work. ( 2016-12-21 09:19:31 -0500 )edit I looked at it, but they use a different laser with a different protocol. That and I have a strong need for the code to be simple (1 file), among more issues. Thank you for checking, though. ( 2016-12-21 09:34:12 -0500 )edit ## 1 Answer Sort by » oldest newest most voted Wooow.... So apparently the solution was that I needed to add${Boost_LIBRARIES} to my target_link_libraries.

more

note also that I later found that \${catkin_LIBRARIES} was missing from target_link_libraries as well

( 2016-12-21 14:40:22 -0500 )edit