Undefined reference to ros::, moveit::, and boost::
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})
What is the difference of "catkin_make executes without problems" and "build ... from the terminal"?
One compiles and one doesn't, besides that, I'm not familiar with how catkin_make behaves
The commands I run are "catkin_make" and "gcc runToolPath.cpp" respectively