CMake链接Open3D和ROS

在尝试将Open3D整合到ROS程序时遇到编译错误,错误提示为未定义的ROS库引用。检查CMakeLists.txt无误后,通过卸载Open3D并重新编译,添加特定的cmake选项(如-DGLIBCXX_USE_CXX11_ABI=ON等)解决了冲突,最终成功编译。
摘要由CSDN通过智能技术生成

最近需要在一个现有的ROS程序中用到Open3D,按照官网实例通过源码安装好之后发现编译不通过,提示找不到ROS相关的库,但是把Open3D相关的去掉就可以成功编译。

/usr/bin/ld: CMakeFiles/odometry_node.dir/src/OdometryServer.cpp.o: in function `SigHandle(int)':
OdometryServer.cpp:(.text+0xe9): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::string const&, ros::console::levels::Level)'
/usr/bin/ld: CMakeFiles/odometry_node.dir/src/OdometryServer.cpp.o: in function `kiss_icp_ros::OdometryServer::lidar_cbk(boost::shared_ptr<sensor_msgs::PointCloud2_<std::allocator<void> > const> const&)':
OdometryServer.cpp:(.text+0xfc4): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::string const&, ros::console::levels::Level)'
/usr/bin/ld: CMakeFiles/odometry_node.dir/src/OdometryServer.cpp.o: in function `kiss_icp_ros::OdometryServer::OdometryServer(ros::NodeHandle const&, ros::NodeHandle const&)':
OdometryServer.cpp:(.text+0x1779): undefined reference to `ros::NodeHandle::hasParam(std::string const&) const'
/usr/bin/ld: OdometryServer.cpp:(.text+0x17ce): undefined reference to `ros::NodeHandle::hasParam(std::string const&) const'
/usr/bin/ld: OdometryServer.cpp:(.text+0x181d): undefined reference to `ros::NodeHandle::hasParam(std::string const&) const'
/usr/bin/ld: OdometryServer.cpp:(.text+0x1869): undefined reference to `ros::NodeHandle::hasParam(std::string const&) const'
/usr/bin/ld: OdometryServer.cpp:(.text+0x18b8): undefined reference to `ros::NodeHandle::hasParam(std::string const&) const'

检查了一下CMakeLists.txt也没有什么问题。

cmake_minimum_required(VERSION 3.16...3.24)
project(kiss_icp)

find_package(
  catkin REQUIRED
  COMPONENTS roscpp
             geometry_msgs
             nav_msgs
             sensor_msgs
             rosbag
             std_msgs
             tf2
             tf2_ros)
catkin_package()

find_package(Open3D REQUIRED)

#
# ROS1 node
add_executable(odometry_node src/Utils.cpp src/OdometryServer.cpp src/odometry_node.cpp src/lio_iekf.cpp)
target_link_libraries(odometry_node kiss_icp::pipeline)

target_include_directories(odometry_node PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ${catkin_INCLUDE_DIRS} ${Open3D_INCLUDE_DIRS})
target_link_libraries(odometry_node ${catkin_LIBRARIES} ${Open3D_LIBRARIES})


install(TARGETS odometry_node RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

最后察觉可能是Open3D在编译的时候可能和ROS的某些package有冲突,于是卸载掉Open3D重新编译安装,在cmake的时候加上以下选项,最后编译成功。

cmake -DBUILD_EIGEN3=ON -DBUILD_GLEW=ON -DBUILD_GLFW=ON -DBUILD_JSONCPP=ON -DBUILD_PNG=ON -DGLIBCXX_USE_CXX11_ABI=ON -DPYTHON_EXECUTABLE=/usr/bin/python -DBUILD_UNIT_TESTS=ON ..
参考

https://www.guyuehome.com/36305

http://www.open3d.org/docs/release/getting_started.html

https://github.com/isl-org/Open3D/issues/3432

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值