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

Undefined reference to ros (melodic)

asked 2020-07-07 09:20:28 -0500

Pombor gravatar image

Hi, i'm on raspbian and try to make a camera vision with ROS and OpenCV but I get errors with ROS...

cmake_minimum_required(VERSION 3.0.2)
project(test)

find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs)

include_directories(${catkin_INCLUDE_DIRS})

add_executable(camera src/camera.cpp)
find_package(OpenCV)
include_directories(${OpenCV_INCLUDE_DIRS})
target_link_libraries(camera ${OpenCV_LIBRARIES})

My CMakeLists.txt

<package format="2">
<name>test</name>
<version>0.0.0</version>
<description>Test caméra OpenCV et ROS</description>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>opencv2</build_depend>
<run_depend>roscpp</run_depend>
<run_depend>rospy</run_depend>
<run_depend>std_msgs</run_depend>
<run_depend>opencv2</run_depend>
</package>

My package.xml

/usr/bin/ld: camera.cpp:(.text+0x1ac): undefined reference to `ros::Rate::Rate(double)'
/usr/bin/ld: camera.cpp:(.text+0x1b0): undefined reference to `ros::ok()'
/usr/bin/ld: camera.cpp:(.text+0x440): undefined reference to `ros::console::initialize()'
/usr/bin/ld: camera.cpp:(.text+0x48c): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, ros::console::levels::Level)'
/usr/bin/ld: camera.cpp:(.text+0x4d0): undefined reference to `ros::console::setLogLocationLevel(ros::console::LogLocation*, ros::console::levels::Level)'
/usr/bin/ld: camera.cpp:(.text+0x4d8): undefined reference to `ros::console::checkLogLocationEnabled(ros::console::LogLocation*)'
/usr/bin/ld: camera.cpp:(.text+0x540): undefined reference to `ros::console::print(ros::console::FilterBase*, void*, ros::console::levels::Level, char const*, int, char const*, char const*, ...)'
/usr/bin/ld: camera.cpp:(.text+0x558): undefined reference to `ros::spinOnce()'
/usr/bin/ld: camera.cpp:(.text+0x564): undefined reference to `ros::Rate::sleep()'
/usr/bin/ld: camera.cpp:(.text+0x5cc): undefined reference to `ros::console::g_initialized'
/usr/bin/ld: camera.cpp:(.text+0x618): undefined reference to `ros::Publisher::~Publisher()'
/usr/bin/ld: camera.cpp:(.text+0x648): undefined reference to `ros::NodeHandle::~NodeHandle()'
/usr/bin/ld: camera.cpp:(.text+0x77c): undefined reference to `ros::Publisher::~Publisher()'
/usr/bin/ld: camera.cpp:(.text+0x7b4): undefined reference to `ros::NodeHandle::~NodeHandle()'

All the cmd commands are working, but impossible to find the ros package and I get no error for "ros.h", so I don't think the problem comes from the include.

Help will be appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2020-07-07 11:44:55 -0500

At minimum, you didn't link against ${catkin_LIBRARIES} nor fill out catkin_package() macro.

You can use this as a relatively complete CMakeLists demo: https://github.com/SteveMacenski/slam... (does outside deps, ros deps, etc)

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-07-07 09:20:28 -0500

Seen: 1,598 times

Last updated: Jul 07 '20