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

roslib reference error

asked 2014-11-06 22:21:34 -0600

Hiro Ono gravatar image

updated 2014-11-11 00:39:24 -0600

130s gravatar image

I did:

string fname = ros::package::getPath("foo")

and got:

test.cpp:(.text+0x424): undefined reference to `ros::package::getPath(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'

Looking at existing discussions, it seems that this is because of failure to link to roslib. https://github.com/ros/ros/issues/58

I upgraded all ros packages and tried again but did not work. Your help will be very appreciated.


ROS version: Hydro OS: Ubuntu 12.04 I installed through apt-get

CMakeList.txt:

cmake_minimum_required(VERSION 2.8.3)

project(ctb)
find_package(catkin REQUIRED COMPONENTS roscpp std_msgs)

catkin_package(
   INCLUDE_DIRS include
   CATKIN_DEPENDS roscpp std_msgs actionlib_msgs actionlib
)

include_directories(include ${catkin_INCLUDE_DIRS})
add_executable(hoge src/PathPlanner/test.cpp)
target_link_libraries(hoge ${catkin_LIBRARIES})

package.xml:

<?xml version="1.0"?>
<package>
  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>roscpp</build_depend>
  <build_depend>roslib</build_depend>
  <build_depend>std_msgs</build_depend>
  <run_depend>roscpp</run_depend>
  <run_depend>roslib</run_depend>
  <run_depend>std_msgs</run_depend>
  <export>
  </export>
</package>
edit retag flag offensive close merge delete

Comments

Please update your question with your CMakeLists.txt, package.xml, OS, ROS version and whether you've installed from source or debs. Without that, we cannot help you.

gvdhoorn gravatar image gvdhoorn  ( 2014-11-07 01:46:04 -0600 )edit

I added the requested info. Thank you very much for your help.

Hiro Ono gravatar image Hiro Ono  ( 2014-11-07 21:12:51 -0600 )edit

Problem solved?

gvdhoorn gravatar image gvdhoorn  ( 2014-11-09 02:27:25 -0600 )edit

Don't know why the whole thread was deleted. I just reverted it back.

130s gravatar image 130s  ( 2014-11-11 00:40:09 -0600 )edit

3 Answers

Sort by ยป oldest newest most voted
8

answered 2014-11-12 15:53:03 -0600

Hiro Ono gravatar image

I actually solved by my self. It was CMakeList.txt. I added roslib to find_package and CATKIN_DEPENDS as below and it worked.

find_package(catkin REQUIRED COMPONENTS roscpp std_msgs)

catkin_package(
   INCLUDE_DIRS include
   CATKIN_DEPENDS roscpp std_msgs actionlib_msgs actionlib
)
edit flag offensive delete link more

Comments

3

In the example shown I can't see that you added roslib in find_pacakge or CATKIN_DEPENDS, but did I understand you correctly that you meant to include them?

Azergoo gravatar image Azergoo  ( 2018-07-13 01:26:09 -0600 )edit

Yes. Adding roslib to find_package works

yashtrikannad gravatar image yashtrikannad  ( 2020-03-08 15:01:28 -0600 )edit
5

answered 2018-07-04 10:09:34 -0600

jeremie gravatar image

Hi, ty Giro Ono, you saved me, even if your code was not completely ok... I solved the issue changing CMakelist.txt AND package.xml

In CMakelist.txt :

find_package(catkin REQUIRED COMPONENTS roscpp  std_msgs rosily)

and

catkin_package(INCLUDE_DIRS include CATKIN_DEPENDS roscpp std_msgs roslib)

In package.xml

  <build_depend>roslib</build_depend> <run_depend>roslib</run_depend>

Pb solved ! (kinetic, c++11, ubuntu 16.04)

edit flag offensive delete link more

Comments

1

You wrote "rosily" in find_package. Did you mean "roslib" instead?

Azergoo gravatar image Azergoo  ( 2018-07-13 01:10:27 -0600 )edit

This worked! I added "roslib" to find_package, CATKIN_DEPENDS and in package.xml I added roslib as <build_depend> and <exec_depend>

Azergoo gravatar image Azergoo  ( 2018-07-13 01:11:56 -0600 )edit
1

answered 2014-11-11 01:28:58 -0600

Wolf gravatar image

I had the same problem caused by some precompiled libs; try running sudo apt-get update and sudo apt-get upgrade to make sure everything installed is up-to-date and delete your workspace lib/devel/install folders and rerun catkin_make to make sure literally everything is recompiled...

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-11-06 22:21:34 -0600

Seen: 6,503 times

Last updated: Jul 04 '18