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

Linker error on ros kinetic + Ubuntu 16.04

asked 2016-05-13 13:12:13 -0600

juancamilog gravatar image

updated 2016-05-17 11:16:05 -0600

I am having trouble running catkin_make with the newest release of ROS. For any package I try to build from my catking workspace, I'm getting linker errors about undefined references to ROS core libraries.

For example, trying to build the gps_umd module from here http://wiki.ros.org/gps_umd :

I get the following errors:

[ 18%] Linking CXX executable /home/juancamilog/aqua_ws/devel/lib/gps_common/utm_odometry_node
CMakeFiles/gps_common/utm_odometry_node.dir/src/utm_odometry_node.cpp.o: In function `callback(boost::shared_ptr<sensor_msgs::NavSatFix_<std::allocator<void> > const> const&)':
utm_odometry_node.cpp:(.text+0xcd3): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::string const&, ros::console::levels::Level)'
CMakeFiles/gps_common/utm_odometry_node.dir/src/utm_odometry_node.cpp.o: In function `main':
utm_odometry_node.cpp:(.text+0x1268): undefined reference to `ros::init(int&, char**, std::string const&, unsigned int)'
utm_odometry_node.cpp:(.text+0x12c4): 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&)'
utm_odometry_node.cpp:(.text+0x133b): 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&)'
CMakeFiles/gps_common/utm_odometry_node.dir/src/utm_odometry_node.cpp.o: In function `void ros::Publisher::publish<nav_msgs::Odometry_<std::allocator<void> > >(nav_msgs::Odometry_<std::allocator<void> > const&) const':
utm_odometry_node.cpp:(.text._ZNK3ros9Publisher7publishIN8nav_msgs9Odometry_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8nav_msgs9Odometry_ISaIvEEEEEvRKT_]+0xa0): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::string const&, ros::console::levels::Level)'
utm_odometry_node.cpp:(.text._ZNK3ros9Publisher7publishIN8nav_msgs9Odometry_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8nav_msgs9Odometry_ISaIvEEEEEvRKT_]+0x1a3): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::string const&, ros::console::levels::Level)'
utm_odometry_node.cpp:(.text._ZNK3ros9Publisher7publishIN8nav_msgs9Odometry_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8nav_msgs9Odometry_ISaIvEEEEEvRKT_]+0x29e): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::string const&, ros::console::levels::Level)'
utm_odometry_node.cpp:(.text._ZNK3ros9Publisher7publishIN8nav_msgs9Odometry_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8nav_msgs9Odometry_ISaIvEEEEEvRKT_]+0x3c1): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::string const&, ros::console::levels::Level)'
utm_odometry_node.cpp:(.text._ZNK3ros9Publisher7publishIN8nav_msgs9Odometry_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8nav_msgs9Odometry_ISaIvEEEEEvRKT_]+0x4c4): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::string const&, ros::console::levels::Level)'
CMakeFiles/gps_common/utm_odometry_node.dir/src/utm_odometry_node.cpp.o:utm_odometry_node.cpp:(.text._ZNK3ros9Publisher7publishIN8nav_msgs9Odometry_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8nav_msgs9Odometry_ISaIvEEEEEvRKT_]+0x5d6): more undefined references to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::string const&, ros::console::levels::Level)' follow
CMakeFiles/gps_common/utm_odometry_node.dir/src/utm_odometry_node.cpp.o: In function `bool ros::NodeHandle::param<std::string>(std::string const&, std::string&, std::string const&) const':
utm_odometry_node.cpp:(.text._ZNK3ros10NodeHandle5paramISsEEbRKSsRT_RKS4_[_ZNK3ros10NodeHandle5paramISsEEbRKSsRT_RKS4_]+0x27): undefined reference to `ros::NodeHandle::hasParam(std::string const&) const'
utm_odometry_node.cpp:(.text._ZNK3ros10NodeHandle5paramISsEEbRKSsRT_RKS4_[_ZNK3ros10NodeHandle5paramISsEEbRKSsRT_RKS4_]+0x42): undefined reference to `ros::NodeHandle::getParam(std::string const&, std::string&) const'
CMakeFiles/gps_common/utm_odometry_node.dir/src/utm_odometry_node.cpp.o: In function `bool ros::NodeHandle::param<double>(std::string const&, double&, double const&) const':
utm_odometry_node.cpp:(.text._ZNK3ros10NodeHandle5paramIdEEbRKSsRT_RKS4_[_ZNK3ros10NodeHandle5paramIdEEbRKSsRT_RKS4_]+0x27): undefined reference to `ros::NodeHandle::hasParam(std::string const&) const'
utm_odometry_node.cpp:(.text._ZNK3ros10NodeHandle5paramIdEEbRKSsRT_RKS4_[_ZNK3ros10NodeHandle5paramIdEEbRKSsRT_RKS4_]+0x42): undefined reference to `ros::NodeHandle::getParam(std::string const&, double&) const'
CMakeFiles/gps_common/utm_odometry_node.dir/src/utm_odometry_node.cpp.o: In function `ros::SubscriptionCallbackHelperT<boost::shared_ptr<sensor_msgs::NavSatFix_<std::allocator<void ...
(more)
edit retag flag offensive close merge delete

Comments

I don't know why the linking is failing, but looking at that package, this line looks strange to me: https://github.com/ktossell/gps_umd/b...

I'm not sure it makes sense to do ${PROJECT_NAME}/ before the executable name. You can try removing those lines.

William gravatar image William  ( 2016-05-13 15:40:04 -0600 )edit

That is normal, it's just specifying a destination folder for the executable. But the problem is not only with this package. The same happens with any package.

juancamilog gravatar image juancamilog  ( 2016-05-17 08:45:26 -0600 )edit

I was using gcc-4.9 as the default. Switching to gcc-5.3.1 makes everything work! But I doubt that this is the answer.

juancamilog gravatar image juancamilog  ( 2016-05-17 11:17:13 -0600 )edit

I also got the same problem after updating my ubuntu from 14.04 to 16.04 : ( catkin_make doesn't link ROS libraries!

francisc0garcia gravatar image francisc0garcia  ( 2016-05-17 12:04:08 -0600 )edit

@francisc0garcia The build farm has successfully built more then 450 packages for Kinetic. All link+run correctly. So it is unlikely a generic problem. It would help if you provide enough information about your case to reproduce it. Then others can try to help you figuring out why it fails for you.

Dirk Thomas gravatar image Dirk Thomas  ( 2016-05-17 12:37:20 -0600 )edit

@dirk-thomas I have upgraded ubuntu from 14.04 to 16.04, install ROS kinetic, I tested the nodes without compiling (OK), then I have compiled and installed OpenCV 3.1, for that, I change the GCC version from 5.3 to 4.8 and after that catkin_make fails. I didn't try it before change GCC version : (

francisc0garcia gravatar image francisc0garcia  ( 2016-05-17 12:48:00 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-05-17 12:39:03 -0600

francisc0garcia gravatar image

I finally solve the problem changing the compiler from gcc-5 to clang. It is not an optimal solution but it works for me:

Ubuntu 14.04 have GCC-4.X and in ubuntu 16.04 the default version is GCC-5.X. first, I try to change the default version using "sudo update-alternatives --config gcc" and selecting GCC-4.8 but it doesn't work for me.

So, simply I add this lines to CMakeLists.txt

set(CMAKE_CXX_COMPILER "clang++")

set(CMAKE_C_COMPILER "clang")

if you need to install clang in ubuntu 16.04: sudo apt-get install clang

I hope It helps you.

edit flag offensive delete link more

Comments

you can also try to set as a C/CXX compiler gcc-5 using:

export CC=/usr/bin/gcc-5 export CXX=/usr/bin/g++-5

and then compile again using catkin_make

francisc0garcia gravatar image francisc0garcia  ( 2016-06-01 02:34:14 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-05-13 13:06:39 -0600

Seen: 4,177 times

Last updated: May 17 '16