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

Undefined Symbol related to moveit core and .....

asked 2018-05-28 07:00:47 -0500

adroit89 gravatar image

updated 2018-06-13 10:42:19 -0500

Hi, I have a project to use MoveIt and planning which its CMakeList is as below:

cmake_minimum_required(VERSION 3.0)

PROJECT(project_one)

set(CMAKE_CXX_STANDARD 11)

find_package(Eigen3 REQUIRED)
find_package(Boost COMPONENTS system REQUIRED)
find_package(catkin REQUIRED COMPONENTS moveit_core moveit_ros_planning rosconsole urdf)

add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY)

add_library(ProjectOne SHARED
    src/ClassA.cpp
    src/ClassB.cpp
    src/ClassC.cpp
    )

target_link_libraries(ProjectOne PRIVATE ${catkin_LIBRARIES}  ${moveit_core_LIBRARIES}  ${ros_console_LIBRARIES}    ${moveit_ros_planning_LIBRARIES})

target_include_directories(ProjectOne PRIVATE include ${EIGEN3_INCLUDE_DIR} ${catkin_INCLUDE_DIRS}  ${moveit_core_INCLUDE_DIRS} ${ros_console_INCLUDE_DIRS} ${moveit_ros_planning_INCLUDE_DIRS})

set_target_properties(PeojectOne PROPERTIES VERSION ${PROJECT_VERSION})

install(DIRECTORY include/
    DESTINATION include/${PROJECT_NAME}
    FILES_MATCHING PATTERN "*.h")

catkin_package(INCLUDE_DIRS include
    CATKIN_DEPENDS roscpp roslib
    DEPENDS)

install(TARGETS ProjectOne
    ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
    LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
    RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
    )

The problem is that it compiles but when I run this command "nm -u ~/catkin_ws/build/projectOne/libProjectOne.so", I get these as undefined: (I demangled them)

robot_model_loader::RobotModelLoader::RobotModelLoader(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)
robot_model_loader::RobotModelLoader::~RobotModelLoader()
ros::console::initialize()
ros::console::g_initialized
ros::console::setLogLocationLevel(ros::console::LogLocation*, ros::console::levels::Level)
ros::console::initializeLogLocation(ros::console::LogLocation*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, ros::console::levels::Level)
ros::console::checkLogLocationEnabled(ros::console::LogLocation*)
ros::console::print(ros::console::FilterBase*, void*, ros::console::levels::Level, char const*, int, char const*, char const*, ...)
ros::console::print(ros::console::FilterBase*, void*, ros::console::levels::Level, std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int, char const*)
moveit::planning_interface::MoveGroupInterface::setNamedTarget(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
moveit::planning_interface::MoveGroupInterface::MoveGroupInterface(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::shared_ptr<tf::Transformer> const&, ros::WallDuration const&)
moveit::planning_interface::MoveGroupInterface::~MoveGroupInterface()
moveit::core::RobotState::setToIKSolverFrame(Eigen::Transform<double, 3, 2, 0>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
moveit::core::RobotState::RobotState(std::shared_ptr<moveit::core::RobotModel const> const&)
moveit::core::RobotState::~RobotState()
moveit::planning_interface::MoveGroupInterface::getJointValueTarget() const
moveit::core::RobotModel::getLinkModel(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const
moveit::core::RobotModel::getJointModel(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const
moveit::core::RobotModel::hasJointModel(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const
moveit::core::RobotModel::getVariableIndex(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const
moveit::core::RobotModel::getJointModelGroup(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const
moveit::core::RobotState::getJacobian(moveit::core::JointModelGroup const*, moveit::core::LinkModel const*, Eigen::Matrix<double, 3, 1, 0, 3, 1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, bool) const
moveit::core::RobotState::copyJointGroupPositions(moveit::core::JointModelGroup const*, Eigen::Matrix<double, -1, 1, 0, -1, 1>&) const

I want to use this package as a library which is not possible due to these undefined symbols. I think it is related to CMakeList options which I may set wrong. Why this happen?

edit retag flag offensive close merge delete

Comments

I see a few things that can go unexpectedly: - If your c++ files require the headers/libraries of other packages, the find_package should use the REQUIRED keyword ...

marguedas gravatar image marguedas  ( 2018-05-28 18:23:04 -0500 )edit

... - The packages you find are ROS packages, so they are catkin components, I'd recommend: - find_package(catkin REQUIRED COMPONENTS moveit_core rosconsole ...) - target_link_libraries(${catkin_LIBRARIES} ...) ...

marguedas gravatar image marguedas  ( 2018-05-28 18:25:02 -0500 )edit

... Note that both target_include_directories (repectively target_link_libraries) should be provided ALL the headers (respectively libraries) that the use symbols from. e.g. you use robot_model_loader::RobotModelLoader... that come from moveit_ros_planning but aren't passed to the target

marguedas gravatar image marguedas  ( 2018-05-28 18:28:59 -0500 )edit

Hi @marguedas. Thanks for your answer. I changed the CMakeList as you said (I edited my question w.r.t this), plus cleaning build and devel. But again those undefined symbols appeared. :(

adroit89 gravatar image adroit89  ( 2018-05-29 05:16:07 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-07-13 07:43:17 -0500

adroit89 gravatar image

Ok, finally I can solve the problem and I learned some new points which I did not attend before as an essential point.

1) catkin_package should always call before add_library. In most usual packages it is not important but when you want to generate a shared library it will be important as I understood. The fact is that in this case when I put add_library before catkin_package the so file created in build directory. So, the other packages cannot find that library. But when I put catkin_package before add_library the so file created in devel/lib. So, it will be available to use by others.

2) About undefined symbol in nm command result, the fact is that it is not exactly mean that there are no definition for these library and lack of real link. The great point which I learned was the fact that it means these functions need some libraries which is not available locally and will be link later from other places. Actually, ldd command helped me to understand this. ldd result was really great and showed all proper path for libraries.

So, now it works.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2018-05-28 07:00:47 -0500

Seen: 638 times

Last updated: Jul 13 '18