【发布时间】:2017-11-17 18:36:01
【问题描述】:
您好,我在 CmakeList 和对 Boost 的依赖方面遇到问题。我的 CmakeList 看起来像这样:
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})
首先我遇到了麻烦,我无法完成 catkin_make。我没有以下代码:
target_link_libraries(cpp_arm ${Boost_LIBRARIES})
这给了我以下错误:
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
查看该错误后,我发现了关于此(堆栈上)的不同主题,说您需要链接 cmakelist 中的 boost 库以让 cmake“找到”它。正如我的代码所示(根据上述主题中描述的语法),我这样做了,但这会导致一个新错误:
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.
当我查看该错误时,我主要看到主题说链接库的语法不正确,问题是我的语法与主题中提到的相同作为解决方案。
为什么会出现此错误,我该如何解决?
提前致谢
编辑:我发现我的项目实际上是什么有些混乱。我正在运行一个通过 MoveIT 设置助手创建的 ROS 包,它在我的 catkin_workspace 中为 ROS 生成一个包。在这个工作空间内,我的包文件夹位于名为 cpp_arm 的位置。在这个包/文件夹内是我的 CmakeList,在这个文件夹内还有一个文件夹 src,其中包含一个简单的 c++ 文件 (test_arm.cpp)。
此 cpp 文件如下所示:
#include <moveit/move_group_interface/move_group_interface.h>
main()
{
}
我在 Ubuntu 16.04 上运行 ROS kinetic 版本
【问题讨论】:
-
你在交叉编译吗?或者你的开发机器是 ARM 的?
cpp_arm是红鲱鱼吗?
标签: c++ boost cmake arm dependencies