Hello I am having troubles with CmakeList and dependencies to Boost. My CmakeList looks like this:
cmake_minimum_required(VERSION 2.8.3)
project(cpp_arm)
add_compile_options(-std=c++11)
find_package(catkin REQUIRED COMPONENTS
moveit_core
)
find_package(Boost REQUIRED COMPONENTS
system
filesystem
date_time
thread
)
catkin_package()
include_directories(${catkin_INCLUDE_DIRS})
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
add_executable(hello_world src/hello_world.cpp)
add_executable(test_arm src/test_arm.cpp)
target_link_libraries(cpp_arm ${Boost_LIBRARIES})
install(DIRECTORY launch DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
PATTERN "setup_assistant.launch" EXCLUDE)
install(DIRECTORY config DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
First I had troubles with this where I couldn´t finish catkin_make. I did not have the following code:
target_link_libraries(cpp_arm ${Boost_LIBRARIES})
This gave me the following error:
CMakeFiles/test_arm.dir/src/test_arm.cpp.o: In function `_GLOBAL__sub_I_main':
test_arm.cpp:(.text.startup+0x43): undefined reference to `boost::system::generic_category()'
test_arm.cpp:(.text.startup+0x48): undefined reference to `boost::system::generic_category()'
test_arm.cpp:(.text.startup+0x4d): undefined reference to `boost::system::system_category()'
collect2: error: ld returned 1 exit status
After looking that error up I have found different topics on this (on stack) saying you need to link the boost library in the cmakelist to let cmake "find" it. I did that as my code shows (accordingly to the syntax described in the mentioned topics) but this results in a new error:
CMake Error at cpp_arm/CMakeLists.txt:25 (target_link_libraries):
Cannot specify link libraries for target "cpp_arm" which is not built by
this project.
When I looked up that error I mainly saw topics saying the syntax of the link libraries was not correct, problem is that my syntax is the same as those mentioned in the topics as solutions.
Why do I get this error and how can I fix this?
Thanks in advance
Edit: I see there is some confusion about what my project actually is. I am running a ROS package that was created through the MoveIT setup assistant which generates a package for ROS in my catkin_workspace. Inside this workspace my package folder is located with the name cpp_arm. Inside this package/folder is my CmakeList and inside this folder is also a folder src which contains a simple c++ file (test_arm.cpp).
This cpp file looks like this:
#include <moveit/move_group_interface/move_group_interface.h>
main()
{
}
I am running ROS kinetic version on Ubuntu 16.04