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

Revision history [back]

So digging a little deeper, I found out that this might be due to ABI incompatibility between gcc-4.8 and gcc-5.

If the linker is complaining that it can not find a reference to ros::init, is because it can really not find it. Looking at the library /opt/ros/kinetic/lib/libroscpp.so we can see the references to ros::init are actually there:

secret_agent@CIA:~/top_secret/catkin_ws/build/roscpp_tutorials$ readelf -Ws /opt/ros/kinetic/lib/libroscpp.so | grep ros4init
  1968: 0000000000130950   566 FUNC    GLOBAL DEFAULT   12 _ZN3ros4initERKSt6vectorISt4pairINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_ESaIS8_EERKS7_j
  2303: 0000000000130170  2010 FUNC    GLOBAL DEFAULT   12 _ZN3ros4initERiPPcRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEj
  2448: 000000000012da80   403 FUNC    GLOBAL DEFAULT   12 _ZN3ros4initERKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_St4lessIS6_ESaISt4pairIKS6_S6_EEERSA_j

Lets look at the object file that we are trying to link:

secret_agent@CIA:~/top_secret/catkin_ws/build/roscpp_tutorials$ nm CMakeFiles/parameters.dir/parameters/parameters.cpp.o | grep ros4init
             U _ZN3ros4initERiPPcRKSsj

Aha!!! The reference generated for ros::init by gcc-4.8 does not match the reference for ros::init in libroscpp!

This is because libroscpp has been compiled with Ubuntu 16.04 default compiler without old ABI backwards compatibility (if I am not mistaken this would be achieved by the flag -D_GLIBCXX_USE_CXX11_ABI=0.

Obviously, compiling the code with the default version (gcc-5) generates the correct references and the linker is happy.

So, I guess my only option would be to compile ROS from source code and pray that all system libraries are ABI compatible with gcc-4.8 which is not practical for my project.

Tough luck -_-

So digging a little deeper, I found out that this might be due to ABI incompatibility between gcc-4.8 and gcc-5.

If the linker is complaining that it can not find a reference to ros::init, is because it can really not find it. Looking at the library /opt/ros/kinetic/lib/libroscpp.so we can see the references to ros::init are actually there:

secret_agent@CIA:~/top_secret/catkin_ws/build/roscpp_tutorials$ readelf -Ws /opt/ros/kinetic/lib/libroscpp.so | grep ros4init
  1968: 0000000000130950   566 FUNC    GLOBAL DEFAULT   12 _ZN3ros4initERKSt6vectorISt4pairINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_ESaIS8_EERKS7_j
  2303: 0000000000130170  2010 FUNC    GLOBAL DEFAULT   12 _ZN3ros4initERiPPcRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEj
  2448: 000000000012da80   403 FUNC    GLOBAL DEFAULT   12 _ZN3ros4initERKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_St4lessIS6_ESaISt4pairIKS6_S6_EEERSA_j

Lets look at the object file that we are trying to link:

secret_agent@CIA:~/top_secret/catkin_ws/build/roscpp_tutorials$ nm CMakeFiles/parameters.dir/parameters/parameters.cpp.o | grep ros4init
             U _ZN3ros4initERiPPcRKSsj

Aha!!! The reference generated for ros::init by gcc-4.8 does not match the reference for ros::init in libroscpp!libroscpp! So, the linker is going bananas and rightfully so!!

This is because libroscpp has been compiled with Ubuntu 16.04 default compiler without old ABI backwards compatibility (if I am not mistaken this would be achieved by the flag -D_GLIBCXX_USE_CXX11_ABI=0.

Obviously, compiling the code with the default version (gcc-5) generates the correct references and the linker is happy.

So, I guess my only option would be to compile ROS from source code and pray that all system libraries are ABI compatible with gcc-4.8 which is not practical for my project.

Tough luck -_-