-
Notifications
You must be signed in to change notification settings - Fork 6
Description
When following the original CMakeLists.txt example, the following errors were encountered (among many others)
...
demo_node.cpp:(.text+0x2fa): undefined reference toboost::system::generic_category()' demo_node.cpp:(.text+0x306): undefined reference toboost::system::system_category()'
...
I propose the following changes to solve these errors:
From CMakeLists line 27 to 34 instead of:
add_executable(demo src/demo/demo.cpp src/demo/demo_node.cpp)
add_dependencies(demo ${catkin_EXPORTED_TARGETS} rosparam_handler_tutorial_gencfg)
target_link_libraries(demo ${catkin_LIBRARIES})
install(TARGETS demo
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
The solution will be to put the add_dependencies tags after "target_link_libraries" and "install":
add_executable(demo src/demo.cpp src/demo_node.cpp)
target_link_libraries(demo ${catkin_LIBRARIES})
install(TARGETS demo
ARCHIVE DESTINATION #{CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
add_dependencies(demo ${CATKIN_EXPORTED_TARGETS} ${PROJECT_NAME}_gencfg)
add_dependencies(demo ${PROJECT_NAME}_genparam)