ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Node can't find roscpp libs

asked 2021-08-17 17:34:01 -0500

LukeAI gravatar image

updated 2021-08-17 18:34:38 -0500

miura gravatar image

Trying to port a node from catkin_make to catkin tools but it won't build - it seems that it can't find any of the roscpp libs and gives a very long stream of errors like this. I have been tearing my hair out at this one. Have I made some typo in CMakelists.txt ?

( yes, I did remember to #include <ros ros.h=""> )

box_filter.cpp:(.text+0x4c8): undefined reference to `ros::Time::now()'                                                                           
CMakeFiles/box_filter.dir/nodes/box_filter.cpp.o: In function `main':                                                                             
box_filter.cpp:(.text+0x6f1): undefined reference to `ros::init(int&, char**, std::__cxx11::basic_string<char, std::char_traits<char>, std::alloca
tor<char> > const&, unsigned int)'                                                                                                                
box_filter.cpp:(.text+0x783): undefined reference to `ros::NodeHandle::NodeHandle(std::__cxx11::basic_string<char, std::char_traits<char>, std::al
locator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char,
 std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std$
:allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::
char_traits<char>, std::allocator<char> > > > > const&)'

package.xml

<?xml version="1.0"?>
<package format="2">
  <name>box_filter</name>
  <version>0.0.0</version>
  <description>The box_filter package</description>

  <maintainer email="me@todo.todo">biao</maintainer>

  <license>TODO</license>

  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>pcl_ros</build_depend>
  <build_export_depend>pcl_ros</build_export_depend>
  <exec_depend>pcl_ros</exec_depend>

  <build_depend>message_generation</build_depend>
  <build_export_depend>message_runtime</build_export_depend>
  <exec_depend>message_runtime</exec_depend>

  <depend>roscpp</depend>
  <depend>std_msgs</depend>
  <depend>sensor_msgs</depend>

  <export>
  </export>
</package>

CMakeLists.txt

 cmake_minimum_required(VERSION 3.0.2)
project(box_filter)
add_compile_options(-std=c++14)

find_package(catkin REQUIRED COMPONENTS
  roscpp
  pcl_ros
  message_generation
  std_msgs
  sensor_msgs
)

add_message_files(
  DIRECTORY msg
  FILES
  Comb_PointCloud2.msg
  box_filter_boundary_msg.msg
)

generate_messages(
  DEPENDENCIES
  std_msgs
  sensor_msgs
)

catkin_package(
  CATKIN_DEPENDS roscpp std_msgs sensor_msgs pcl_ros message_runtime
)

include_directories(include ${catkin_INCLUDE_DIRS})

add_executable(box_filter
         nodes/box_filter.cpp)
add_dependencies(box_filter ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

install(TARGETS
   box_filter
   ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
   LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
   RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
)

install(DIRECTORY launch/
        DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
        PATTERN ".svn" EXCLUDE)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-08-17 18:46:43 -0500

miura gravatar image

You are probably missing the following. This is why the library cannot be linked.

target_link_libraries(box_filter ${catkin_LIBRARIES})
edit flag offensive delete link more

Comments

1

Indeed, the build script is not linking to any libraries whatsoever.

I'm really curious how this would have ever built with catkin_make. There's nothing which catkin_tools does fundamentally different which would affect this particular part.


Edit: @LukeAI: have you seen the PCL nodelets provided by pcl_ros? I'm not 100% sure, but it's possible a "box filter" is included. Nodelets would be more performant in any case, if it's possible to use them.

gvdhoorn gravatar image gvdhoorn  ( 2021-08-18 03:16:18 -0500 )edit
1

I haven't, will look into them, thankyou

LukeAI gravatar image LukeAI  ( 2021-08-18 03:38:28 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2021-08-17 17:34:01 -0500

Seen: 137 times

Last updated: Aug 17 '21