0
$\begingroup$

Rosanswers logo

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> > const> const&, void>::deserialize(ros::SubscriptionCallbackHelperDeserializeParams const&)':
utm_odometry_node.cpp:(.text._ZN3ros27SubscriptionCallbackHelperTIRKN5boost10shared_ptrIKN11sensor_msgs10NavSatFix_ISaIvEEEEEvE11deserializeERKNS_43SubscriptionCallbackHelperDeserializeParamsE[_ZN3ros27SubscriptionCallbackHelperTIRKN5boost10shared_ptrIKN11sensor_msgs10NavSatFix_ISaIvEEEEEvE11deserializeERKNS_43SubscriptionCallbackHelperDeserializeParamsE]+0xba): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::string const&, ros::console::levels::Level)'
collect2: error: ld returned 1 exit status
gps_umd/gps_common/CMakeFiles/gps_common/utm_odometry_node.dir/build.make:114: recipe for target '/home/juancamilog/aqua_ws/devel/lib/gps_common/utm_odometry_node' failed
make[2]: *** [/home/juancamilog/aqua_ws/devel/lib/gps_common/utm_odometry_node] Error 1
CMakeFiles/Makefile2:1101: recipe for target 'gps_umd/gps_common/CMakeFiles/gps_common/utm_odometry_node.dir/all' failed
make[1]: *** [gps_umd/gps_common/CMakeFiles/gps_common/utm_odometry_node.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j1" failed

This is happening with any ros package with cpp nodes under my workspace. The packages are compiled fine on another machine running 15.04 and ROS Jade. Do we need to do any migration from Jade to Kinetic related to this problem?

UPDATE

Because of a dependency from another library I'm using (Theano), I had changed the default gcc version to 4.9, via the update-alternatives --config command. After switching the default gcc version to 5.3.1, the code compiles without problems. Which is odd, because here it is mentioned that Kinetic Kame shoudl work with gcc 4.9.


Originally posted by juancamilog on ROS Answers with karma: 13 on 2016-05-13

Post score: 1


Original comments

Comment by William on 2016-05-13:
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/blob/master/gps_common/CMakeLists.txt#L43

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

Comment by juancamilog on 2016-05-17:
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.

Comment by juancamilog on 2016-05-17:
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.

Comment by francisc0garcia on 2016-05-17:
I also got the same problem after updating my ubuntu from 14.04 to 16.04 : ( catkin_make doesn't link ROS libraries!

Comment by Dirk Thomas on 2016-05-17:
@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.

Comment by francisc0garcia on 2016-05-17:
@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 : (

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by francisc0garcia with karma: 51 on 2016-05-17

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by francisc0garcia on 2016-06-01:
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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.