Ask Your Question
0

kdl_parser build error

asked 2020-10-15 09:10:17 -0500

Confused Lizard gravatar image

updated 2020-10-15 16:25:09 -0500

Ubuntu 18.04

ROS_VERSION : melodic

I am obtaining the following error when trying to using the KDL parser (to read a urdf from the parameter server) from the tutorial.

It seems the error come from some dependencies using c++11 instead c++14

CMakeFiles/human_model_pkg_node.dir/src/main_node.cpp.o: In function `main':
main_node.cpp:(.text+0x69): undefined reference to `KDL::Tree::Tree(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
main_node.cpp:(.text+0xfb): undefined reference to `ros::NodeHandle::NodeHandle(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > const&)'
main_node.cpp:(.text+0x1f9): undefined reference to `kdl_parser::treeFromString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, KDL::Tree&)'
main_node.cpp:(.text+0x20b): undefined reference to `ros::console::g_initialized'
main_node.cpp:(.text+0x21b): undefined reference to `ros::console::initialize()'
main_node.cpp:(.text+0x274): 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)'
main_node.cpp:(.text+0x2b7): undefined reference to `ros::console::setLogLocationLevel(ros::console::LogLocation*, ros::console::levels::Level)'
main_node.cpp:(.text+0x2c3): undefined reference to `ros::console::checkLogLocationEnabled(ros::console::LogLocation*)'
main_node.cpp:(.text+0x31e): undefined reference to `ros::console::print(ros::console::FilterBase*, void*, ros::console::levels::Level, char const*, int, char const*, char const*, ...)'
main_node.cpp:(.text+0x34c): undefined reference to `ros::NodeHandle::~NodeHandle()'
main_node.cpp:(.text+0x460): undefined reference to `ros::NodeHandle::~NodeHandle()'
CMakeFiles/human_model_pkg_node.dir/src/main_node.cpp.o: In function `KDL::TreeElement::~TreeElement()':
main_node.cpp:(.text._ZN3KDL11TreeElementD2Ev[_ZN3KDL11TreeElementD5Ev]+0x26): undefined reference to `KDL::Segment::~Segment()'
CMakeFiles/human_model_pkg_node.dir/src/main_node.cpp.o: In function `bool ros::NodeHandle::param<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const':
main_node.cpp:(.text._ZNK3ros10NodeHandle5paramINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEbRKS7_RT_RKSA_[_ZNK3ros10NodeHandle5paramINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEbRKS7_RT_RKSA_]+0x27): undefined reference to `ros::NodeHandle::hasParam(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
main_node.cpp:(.text._ZNK3ros10NodeHandle5paramINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEbRKS7_RT_RKSA_[_ZNK3ros10NodeHandle5paramINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEbRKS7_RT_RKSA_]+0x42): undefined reference to `ros::NodeHandle::getParam(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) const'
collect2: error: ld returned 1 exit status
make[2]: *** [/wp/ros_wp/devel/.private/human_model_pkg/lib/human_model_pkg/human_model_pkg_node] Error 1

the package.xml is

  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>geometry_msgs</build_depend>
  <build_depend>roscpp</build_depend>
  <build_depend>rospy</build_depend>
  <build_depend>kdl_parser</build_depend>
  <build_export_depend>geometry_msgs</build_export_depend>
  <build_export_depend>roscpp</build_export_depend>
  <build_export_depend>rospy</build_export_depend>
  <build_export_depend>kdl_parser</build_export_depend>
  <exec_depend>geometry_msgs</exec_depend>
  <exec_depend>roscpp</exec_depend>
  <exec_depend>rospy</exec_depend>
  <exec_depend>kdl_parser</exec_depend>

I specified these following flags in my CMakeLists.txt

set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 14)               
add_compile_options(-std=c++14)

Edit: trying to add orocos_kdl in xml and the cmakelist doesn't change anything.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-10-16 06:43:12 -0500

main_node.cpp:(.text+0x34c): undefined reference to `ros::NodeHandle::~NodeHandle()'

It's getting the error, so it may be that the link settings are missing. Adding the following to CMakeLists.txt may solve the problem.

target_link_libraries(main_node ${catkin_LIBRARIES})

The part of main_node must be aligned with add_executable.

add_executable(main_node src/main_node.cpp)
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2020-10-15 09:10:17 -0500

Seen: 21 times

Last updated: Oct 16