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

FabianKu's profile - activity

2018-05-23 14:35:16 -0500 received badge  Famous Question (source)
2018-05-23 12:21:36 -0500 answered a question Linking problem with ${catkin_LIBRARIES}

Thanks a lot for your help guys! With the default gcc compiler (in my case 5.4.0) I was able to build the packages. Ther

2018-05-23 12:11:28 -0500 marked best answer Linking problem with ${catkin_LIBRARIES}

Hi everyone!

I'm currently trying to become familiar with ROS (I'm using Kinetic on Ubuntu 16.04 LTS) and followed the beginner tutorials. However, when I try to build the simple publisher/subscriber with catkin_make ( http://wiki.ros.org/ROS/Tutorials/Wri... , Section 3.), I get the following error:

[ 64%] Built target beginner_tutorials_generate_messages_py
[ 70%] Linking CXX executable /home/fabian/catkin_ws/devel/lib/beginner_tutorials/talker
[ 82%] Built target beginner_tutorials_generate_messages_nodejs
[ 88%] Linking CXX executable /home/fabian/catkin_ws/devel/lib/beginner_tutorials/listener
[ 88%] Built target beginner_tutorials_generate_messages
CMakeFiles/talker.dir/src/talker.cpp.o: In function `main':
talker.cpp:(.text+0x70): undefined reference to `ros::init(int&, char**, std::string const&, unsigned int)'
talker.cpp:(.text+0xcc): undefined reference to `ros::NodeHandle::NodeHandle(std::string const&, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > > const&)'
talker.cpp:(.text+0x29a): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::string const&, ros::console::levels::Level)'

etc...

So from my understanding (I did quite a lot of research in several discussion forums), this error actually appears, because the ROS libraries are not linked correctly to the executable. In my CMakeLists.txt I made sure that I added target_link_libraries(listener ${catkin_LIBRARIES}), the CMakeLists.txt looks as follows:

cmake_minimum_required(VERSION 2.8.3)
project(beginner_tutorials)

## Find catkin and any catkin packages
find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs genmsg)

## Declare ROS messages and services
add_message_files(FILES Num.msg)
add_service_files(FILES AddTwoInts.srv)

## Generate added messages and services
generate_messages(DEPENDENCIES std_msgs)

## Declare a catkin package
catkin_package()

## Build talker and listener
include_directories(include ${catkin_INCLUDE_DIRS})

add_executable(talker src/talker.cpp)
## Debug Message
message(STATUS "catkin_LIBRARIES: " ${catkin_LIBRARIES})
target_link_libraries(talker ${catkin_LIBRARIES})
add_dependencies(talker beginner_tutorials_generate_messages_cpp)

add_executable(listener src/listener.cpp)
## Debug Message
message(STATUS "catkin_LIBRARIES: " ${catkin_LIBRARIES})
target_link_libraries(listener ${catkin_LIBRARIES})
add_dependencies(listener beginner_tutorials_generate_messages_cpp)

For debug purposes I added the message command to double-check the value of ${catkin_LIBRARIES}, it is

/opt/ros/kinetic/lib/libroscpp.so/usr/lib/x86_64-linux-gnu/libboost_filesystem.so/usr/lib/x86_64-linux-gnu/libboost_signals.so/opt/ros/kinetic/lib/librosconsole.so/opt/ros/kinetic/lib/librosconsole_log4cxx.so/opt/ros/kinetic/lib/librosconsole_backend_interface.so/usr/lib/x86_64-linux-gnu/liblog4cxx.so/usr/lib/x86_64-linux-gnu/libboost_regex.so/opt/ros/kinetic/lib/libxmlrpcpp.so/opt/ros/kinetic/lib/libroscpp_serialization.so/opt/ros/kinetic/lib/librostime.so/opt/ros/kinetic/lib/libcpp_common.so/usr/lib/x86_64-linux-gnu/libboost_system.so/usr/lib/x86_64-linux-gnu/libboost_thread.so/usr/lib/x86_64-linux-gnu/libboost_chrono.so/usr/lib/x86_64-linux-gnu/libboost_date_time.so/usr/lib/x86_64-linux-gnu/libboost_atomic.so/usr/lib/x86_64-linux-gnu/libpthread.so/usr/lib/x86_64-linux-gnu/libconsole_bridge.so

Since I'm pretty new to ROS and Ubuntu in general, I don't really know how to proceed. Seems like someone had a similar problem before, but never really solved it: https://answers.ros.org/question/2062...

So if you have any ideas on that, let me know.

Thanks in advance!

EDIT 01: Added Code of listener.cpp and talker.cpp

listener.cpp

#include "ros/ros.h"
#include "std_msgs/String.h"

/**
 * This tutorial demonstrates simple receipt of messages ...
(more)
2018-05-23 12:11:28 -0500 received badge  Scholar (source)
2018-05-23 00:11:48 -0500 received badge  Notable Question (source)
2018-05-22 18:57:50 -0500 received badge  Popular Question (source)
2018-05-22 18:47:58 -0500 commented answer Linking problem with ${catkin_LIBRARIES}

Thanks for the answer, but unfortunately it didn't help. I'm already sourcing /opt/ros/kinetic/setup.bash and /home/fabi

2018-05-22 15:47:02 -0500 commented question Linking problem with ${catkin_LIBRARIES}

To be honest, I just copied the code from this tutorial: http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber(c+

2018-05-22 15:44:11 -0500 edited question Linking problem with ${catkin_LIBRARIES}

Linking problem with ${catkin_LIBRARIES} Hi everyone! I'm currently trying to become familiar with ROS (I'm using Kinet

2018-05-22 13:39:20 -0500 asked a question Linking problem with ${catkin_LIBRARIES}

Linking problem with ${catkin_LIBRARIES} Hi everyone! I'm currently trying to become familiar with ROS (I'm using Kinet