Undefined Symbol related to moveit core and .....
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?
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 theREQUIRED
keyword ...... - 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} ...) ...
... Note that both
target_include_directories
(repectivelytarget_link_libraries
) should be provided ALL the headers (respectively libraries) that the use symbols from. e.g. you userobot_model_loader::RobotModelLoader...
that come frommoveit_ros_planning
but aren't passed to the targetHi @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. :(