Ask Your Question
0

not linking with roscpp

asked 2016-03-01 13:33:43 -0500

codenotes gravatar image

updated 2016-03-02 02:43:15 -0500

gvdhoorn gravatar image

Getting linking errors on everything in roscpp, serialization, console, etc. CMakelist looks correct (have read and tried all recommend postings. Can also compile other parts of the package that link with roscpp.). The failure occurs on with this library. Type of errors are like: undefined reference toros::console::initialize()'` for example.

This is the cmakelist.txt, and it references roscpp, and also catkin_LIBRARIES has the correct capitalization...everything seems as it should be. Apologies for the formatting, used "code block" but it doesn't stick.

cmake_minimum_required(VERSION 2.8.3)
project(imu_complementary_filter)

find_package(catkin REQUIRED COMPONENTS
  cmake_modules
  message_filters
  roscpp
  sensor_msgs
  std_msgs
  tf
  genmsg

)

find_package(Eigen REQUIRED COMPONENTS)

catkin_package(
  DEPENDS Eigen
  INCLUDE_DIRS include
  LIBRARIES complementary_filter
  CATKIN_DEPENDS message_filters roscpp sensor_msgs std_msgs tf 
)

include_directories(
  include
  ${catkin_INCLUDE_DIRS}
  ${Eigen_INCLUDE_DIRS}
)

add_library(complementary_filter
  src/complementary_filter.cpp
  src/complementary_filter_ros.cpp
  include/imu_complementary_filter/complementary_filter.h
  include/imu_complementary_filter/complementary_filter_ros.h
)

add_executable(complementary_filter_node
  src/complementary_filter_node.cpp)
target_link_libraries(complementary_filter_node complementary_filter ${catkin_LIBRARIES} ${Eigen_LIBRARIES})

install(TARGETS complementary_filter complementary_filter_node
  ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)


install(DIRECTORY include/${PROJECT_NAME}/
  DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
  FILES_MATCHING PATTERN "*.h"
  PATTERN ".svn" EXCLUDE
)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-03-01 13:51:31 -0500

Dirk Thomas gravatar image

Your question "not linking with roscpp" is already the answer. Your posted CMake code does not link the library against roscpp. You need to call target_link_libraries(complementary_filter ${catkin_LIBRARIES}) (and maybe also eigen).

edit flag offensive delete link more

Comments

there is the line:

target_link_libraries(complementary_filter_node complementary_filter ${catkin_LIBRARIES}

should that not be sufficent? catkin_LIBRARIES includes roscpp, right?

codenotes gravatar imagecodenotes ( 2016-03-01 14:19:16 -0500 )edit

That line is for the executable. You need the same for the library if it already needs roscpp.

Dirk Thomas gravatar imageDirk Thomas ( 2016-03-01 14:47:03 -0500 )edit

100% correct, that solved it. the library needed its own target_link, I missed that. Although mystery as to why that was missing...this is a used public repo. But thank you. For reference, the package here is imu_tools: https://github.com/ccny-ros-pkg/imu_t...

codenotes gravatar imagecodenotes ( 2016-03-01 15:22:23 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-03-01 13:33:43 -0500

Seen: 502 times

Last updated: Mar 02 '16