Skip to content

Solution to error when building the package  #5

@JohnTGZ

Description

@JohnTGZ

When following the original CMakeLists.txt example, the following errors were encountered (among many others)

...
demo_node.cpp:(.text+0x2fa): undefined reference to boost::system::generic_category()' demo_node.cpp:(.text+0x306): undefined reference to boost::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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions