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

catkin_make linking error

asked 2013-09-02 11:56:05 -0500

MarkyMark2012 gravatar image

updated 2013-11-18 16:43:04 -0500

tfoote gravatar image

Hi All,

I've upgraded to groovy & catkin - unfortunately my own code won't link (One of the beginner tutorial does that I used as a test)

Very similar problems I've looked at here hoping to find a pointer to the solution I get errors like:

undefined reference to `ros::Publisher::~Publisher()'ToeminatorROSBridge.cpp (.text+0x384): undefined reference to `ros::NodeHandle::~NodeHandle()'

CMakeFile is:

cmake_minimum_required(VERSION 2.8.3)
project(toeminator_ros_bridge)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages 
find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs tf geometry_msgs     nav_msgs)

## System dependencies are found with CMake's conventions
find_package(Boost REQUIRED COMPONENTS system)
find_package(Boost REQUIRED COMPONENTS thread)

find_package(catkin REQUIRED COMPONENTS message_generation std_msgs sensor_msgs)

generate_messages(
   DEPENDENCIES geometry_msgs   nav_msgs   std_msgs )
## Your package locations should be listed before other locations
include_directories(include ${catkin_INCLUDE_DIRS})

## Declare a cpp executable
add_executable(toeminator_ros_bridge_node src/ToeminatorROSBridge.cpp src/RobotInterface.cpp src/NetworkInterface.cpp )

## Add cmake target dependencies of the executable/library
## as an example, message headers may need to be generated before nodes
# add_dependencies(toeminator_ros_bridge_node toeminator_ros_bridge_generate_messages_cpp)

target_link_libraries(toeminator_ros_bridge_node ${catkin_LIBRARIES})

and extract from package.xml

<buildtool_depend>catkin</buildtool_depend>
<build_depend>geometry_msgs</build_depend>
<build_depend>nav_msgs</build_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>tf</build_depend>
<run_depend>geometry_msgs</run_depend>
<run_depend>nav_msgs</run_depend>
<run_depend>roscpp</run_depend>
<run_depend>rospy</run_depend>
<run_depend>std_msgs</run_depend>
<run_depend>tf</run_depend>

Many Thanks

Mark

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2014-05-15 06:09:03 -0500

LikeSmith gravatar image

updated 2014-05-15 06:20:18 -0500

Have you added the line 'target_link_libraries(toeminator_ros_brigde_node ${catkin_LIBRARIES})' to your CMakeLists.txt file?

Also, are you trying to compile all three source files to a single executable in the add_executable line? As written, it will generate a single executable call toeminator_ros_bridge_node. If you want to make three nodes, you will need three add_executable calls for example:

add_executable(ToeminatorROSBridge src/ToeminatorROSBridge.cpp)
add_executable(RobotInterface src/RobotInterface.cpp)
add_executable(NetworkInterface src/NetworkInterface.cpp)

you would also need to add a target_link_libraries line for each target.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2013-09-02 11:56:05 -0500

Seen: 2,280 times

Last updated: May 15 '14