MoveIt undefined reference when declared inside the function
Hello,
I am using Using ROS Kinetic, Ubuntu 16.04. I try to create a variable of MoveGroupInterface in my class as:
#include <moveit/move_group_interface/move_group_interface.h>
Class Test{
private:
moveit::planning_interface::MoveGroupInterface right_arm;
}
It throws me the following error. I suspected its a linking error, however, I checked my CmakeLists.txt and I guess it looks fine:
Error:
/home/artc/catkin_ws/devel/lib/libsw_lib.so: undefined reference to `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&)'
/home/artc/catkin_ws/devel/lib/libsw_lib.so: undefined reference to `moveit::planning_interface::MoveGroupInterface::~MoveGroupInterface()'
collect2: error: ld returned 1 exit status
sawyer_robot/sawyer_interface/CMakeFiles/sw_node.dir/build.make:179: recipe for target '/home/artc/catkin_ws/devel/lib/sawyer_interface/sw_node' failed
make[2]: *** [/home/artc/catkin_ws/devel/lib/sawyer_interface/sw_node] Error 1
CMakeFiles/Makefile2:7765: recipe for target 'sawyer_robot/sawyer_interface/CMakeFiles/sw_node.dir/all' failed
make[1]: *** [sawyer_robot/sawyer_interface/CMakeFiles/sw_node.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
CmakeLists.txt
cmake_minimum_required(VERSION 2.8.3)
project(sawyer_interface)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
find_package(catkin REQUIRED COMPONENTS
moveit_core
moveit_ros_planning
moveit_ros_planning_interface
moveit_visual_tools
intera_core_msgs
geometry_msgs
cmake_modules
roscpp
rospy
std_msgs
message_generation
)
find_package(Eigen3 REQUIRED)
find_package(Boost REQUIRED system thread)
catkin_package(
CATKIN_DEPENDS roscpp rospy std_msgs moveit_ros_planning moveit_ros_planning_interface moveit_core trajectory_msgs
INCLUDE_DIRS include
LIBRARIES tcp_comms
)
include_directories(include
${catkin_INCLUDE_DIRS}
${Boost_INCLUDE_DIR}
${EIGEN3_INCLUDE_DIRS}
)
add_library(sw_lib
src/sw.cpp
)
add_dependencies(sw_lib ${catkin_EXPORTED_TARGETS})
add_executable(sw_node src/sw_node.cpp)
add_dependencies(sw_node ${catkin_EXPORTED_TARGETS} sw_lib)
target_link_libraries(sw_node ${catkin_LIBRARIES} sw_lib)
install(TARGETS sw_lib sw_node
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
install(
DIRECTORY include/${PROJECT_NAME}
DESTINATION include
)
install(DIRECTORY launch/
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
PATTERN ".svn" EXCLUDE)
if(CATKIN_ENABLE_TESTING)
find_package(rostest REQUIRED)
endif()
At first glance nothing looks wrong - although the CMAKE_CXX_FLAGS code is a mess...
Is your package.xml correct and updated? See https://answers.ros.org/question/2714...
Sadly I can't test this right now.
Hi, @v4hn Michael, I have already zipped and attached my package in the moveit user's group. You should be able to catkin_make and be able to reproduce this error. I have been through all these, and I guess my package.xml is right.