Ask Your Question
0

Undefined reference on roscpp functions

asked 2015-06-02 09:02:56 -0600

francoisdtf gravatar image

updated 2015-06-02 09:09:25 -0600

Hi everyone,

I'm stuck with a linking problem for a while now, I tried many stuff and browsed the forum but couldn't find my exact problem. It must be quite stupid though, since it seems to be a simple fail in linking roscpp.

When I tried to catkin_make my workspace, I get an undefined reference to any function from roscpp. It does not seem to be an inclusion problem since I have no error message about that, only this undefined reference issue.

I simplified my .cpp and my CMakelist.txt to the maximum but still get the same problem. Here are the exact files I'm trying :

CMakelist.txt :

cmake_minimum_required(VERSION 2.8.3)
project(myproject)

if(UNIX)
  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif()


find_package(
  catkin REQUIRED COMPONENTS
  roscpp
  rospy
  )

include_directories(
  include
  ${catkin_INCLUDE_DIRS}
  )


catkin_package(
  INCLUDE_DIRS include
  LIBRARIES myproject
  CATKIN_DEPENDS roscpp rospy
  DEPENDS system_lib
  )

add_executable(lj_cmd_interface src/lj_cmd_interface.cpp)


target_link_libraries(lj_cmd_interface ${CATKIN_LIBRARIES})

package.xml :

<?xml version="1.0"?>
<package>
  <name>myproject</name>
  <version>0.0.0</version>
  <description></description>

  <maintainer email="me@me.com">Me</maintainer>

  <license>BSD</license>

  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>roscpp</build_depend>
  <build_depend>rospy</build_depend>
  <run_depend>roscpp</run_depend>
  <run_depend>rospy</run_depend>

</package>

And even the simplest cpp code doesn't work :

#include "ros/ros.h"

int main(int argc, char **argv){

  ros::init(argc, argv, "mynode");

  return 0;
}

I guess the solution must be quite straightforward once you get it, but after almost a whole day searching for it I must admit I couldn't see it...

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2015-06-02 09:09:31 -0600

gvdhoorn gravatar image
target_link_libraries(lj_cmd_interface ${CATKIN_LIBRARIES})

If that is an actualy copy/paste, then you should change CATKIN_LIBRARIES to catkin_LIBRARIES (note the case change).

edit flag offensive delete link more

Comments

That was an actual copy paste. Thank you and sorry for the trouble, that was the issue.

francoisdtf gravatar imagefrancoisdtf ( 2015-06-02 09:13:28 -0600 )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: 2015-06-02 09:02:56 -0600

Seen: 206 times

Last updated: Jun 02 '15