roslib reference error
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>
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.I added the requested info. Thank you very much for your help.
Problem solved?
Don't know why the whole thread was deleted. I just reverted it back.