Undefined reference to ros::, moveit::, and boost::

asked 2017-06-22 13:59:45 -0500

cvancleef gravatar image

updated 2017-06-22 14:00:22 -0500

I have a package with a couple of .cpp files. Running catkin_make executes without any problems, but if I try to build my cpp files from the terminal or my IDE, I get undefined reference errors. Here are some of the many undefined references errors I get:

runToolpath.cpp:(.text+0x61): undefined reference to `ros::init(int&, char**, std::string const&, unsigned int)'
runToolpath.cpp:(.text+0xbd): undefined reference to `ros::NodeHandle::NodeHandle(std::string const&, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > > const&)'
runToolpath.cpp:(.text+0xef): undefined reference to `ros::AsyncSpinner::AsyncSpinner(unsigned int)'

Here's my CMakeLists.txt

cmake_minimum_required(VERSION 2.8.3)
project(fanuc_lrmate200id_moveit_config)
add_compile_options(-std=c++11)
find_package(catkin REQUIRED COMPONENTS roscpp std_msgs
    moveit_core
    moveit_ros_planning
    moveit_ros_planning_interface
    pluginlib
    tf2
    geometric_shapes
moveit_visual_tools
descartes_moveit
descartes_planner)

find_package(Eigen3 REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIRS})

catkin_package(CATKIN_DEPENDS
    moveit_core
    moveit_ros_planning_interface
    interactive_markers
moveit_visual_tools
descartes_moveit
descartes_planner
  DEPENDS
EIGEN3)

install(DIRECTORY launch DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
install(DIRECTORY config DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})

install(FILES readme.md DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})

include_directories(include ${catkin_INCLUDE_DIRS})

add_executable(MotionControl MotionControl.cpp)

target_link_libraries(MotionControl ${catkin_LIBRARIES})
add_executable(setup_kb02 setup_kb02.cpp)
target_link_libraries(setup_kb02 ${catkin_LIBRARIES})
add_executable(runToolpath runToolpath.cpp)
target_link_libraries(runToolpath ${catkin_LIBRARIES})
edit retag flag offensive close merge delete

Comments

What is the difference of "catkin_make executes without problems" and "build ... from the terminal"?

dornhege gravatar image dornhege  ( 2017-06-23 07:17:29 -0500 )edit

One compiles and one doesn't, besides that, I'm not familiar with how catkin_make behaves

cvancleef gravatar image cvancleef  ( 2017-06-23 07:29:27 -0500 )edit

The commands I run are "catkin_make" and "gcc runToolPath.cpp" respectively

cvancleef gravatar image cvancleef  ( 2017-06-23 07:35:51 -0500 )edit