Node can't find roscpp libs
Trying to port a node from catkin_make to catkin tools but it won't build - it seems that it can't find any of the roscpp libs and gives a very long stream of errors like this. I have been tearing my hair out at this one. Have I made some typo in CMakelists.txt ?
( yes, I did remember to #include <ros ros.h=""> )
box_filter.cpp:(.text+0x4c8): undefined reference to `ros::Time::now()'
CMakeFiles/box_filter.dir/nodes/box_filter.cpp.o: In function `main':
box_filter.cpp:(.text+0x6f1): undefined reference to `ros::init(int&, char**, std::__cxx11::basic_string<char, std::char_traits<char>, std::alloca
tor<char> > const&, unsigned int)'
box_filter.cpp:(.text+0x783): undefined reference to `ros::NodeHandle::NodeHandle(std::__cxx11::basic_string<char, std::char_traits<char>, std::al
locator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std$
:allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::
char_traits<char>, std::allocator<char> > > > > const&)'
package.xml
<?xml version="1.0"?>
<package format="2">
<name>box_filter</name>
<version>0.0.0</version>
<description>The box_filter package</description>
<maintainer email="me@todo.todo">biao</maintainer>
<license>TODO</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>pcl_ros</build_depend>
<build_export_depend>pcl_ros</build_export_depend>
<exec_depend>pcl_ros</exec_depend>
<build_depend>message_generation</build_depend>
<build_export_depend>message_runtime</build_export_depend>
<exec_depend>message_runtime</exec_depend>
<depend>roscpp</depend>
<depend>std_msgs</depend>
<depend>sensor_msgs</depend>
<export>
</export>
</package>
CMakeLists.txt
cmake_minimum_required(VERSION 3.0.2)
project(box_filter)
add_compile_options(-std=c++14)
find_package(catkin REQUIRED COMPONENTS
roscpp
pcl_ros
message_generation
std_msgs
sensor_msgs
)
add_message_files(
DIRECTORY msg
FILES
Comb_PointCloud2.msg
box_filter_boundary_msg.msg
)
generate_messages(
DEPENDENCIES
std_msgs
sensor_msgs
)
catkin_package(
CATKIN_DEPENDS roscpp std_msgs sensor_msgs pcl_ros message_runtime
)
include_directories(include ${catkin_INCLUDE_DIRS})
add_executable(box_filter
nodes/box_filter.cpp)
add_dependencies(box_filter ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
install(TARGETS
box_filter
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
)
install(DIRECTORY launch/
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
PATTERN ".svn" EXCLUDE)