我正在尝试使用 Cmake 编译一个简单的 ROS/cpp 项目,但我在 boost 库时遇到了问题...
我使用的 Cmake:
cmake_minimum_required(VERSION 2.8.3)
project(laserprojection)
#add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
geometry_msgs
message_generation
)
find_package(Boost 1.65.0 REQUIRED COMPONENTS system thread filesystem)
find_package(Eigen3 REQUIRED)
include_directories(${catkin_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR} ${Boost_INCLUDE_DIRS})
add_executable(main main.cpp)
我的 cmake 命令显示找到了 Boost:
Boost version: 1.65.1
Found the following Boost libraries:
system
thread
filesystem
chrono
date_time
atomic
我的 main.cpp :
#include <ros/ros.h>
#include <tf/transform_listener.h>
#include <laser_geometry/laser_geometry.h>
这是我的错误:
........
main.cpp:(.text+0x63) : référence indéfinie vers « boost::system::generic_category() »
main.cpp:(.text+0x6f) : référence indéfinie vers « boost::system::generic_category() »
main.cpp:(.text+0x7b) : référence indéfinie vers « boost::system::system_category() »
.......
最佳答案
因为你没有 Boost 1.66,你需要链接到 boost::system:
add_executable(main main.cpp)
target_link_libraries(main ${Boost_SYSTEM_LIBRARY})
关于c++ - 对 boost::system 的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54647889/