ROS Indigo下boost 1.6及PCL 1.8的编译

ROS indigo版本的boost自带是1.54,PCL默认版本是1.7。

安装PCL 1.8需要boost≥1.56,因此就有了boost 的升级,我这里用的是boost 1.61。建议boost 1.61和PCL 1.8都安装在自己的目录下,不要和系统的混在一起。

https://blog.csdn.net/yaoxiaokui/article/details/49183909

./bootstrap.sh --prefix=/home/yake/Downloads/boost_1_61_0/yake_boost161_installed
./b2 install
查看链接库的版本
ldconfig -p | less |grep boost

/usr/share/cmake-3.2/Modules

这里有个问题需要注意下,在使用PCL 1.8的时候一定要和boost 1.61共用,它需要依赖于boost。

安装好以后,CMakeLists.txt的写法如下:

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

project(pcl_1.8)

#/home/yake/ProgramFiles/yake_pcl180_installed/share/pcl-1.8/PCLConfig.cmake
SET(PCL_DIR /home/yake/ProgramFiles/yake_pcl180_installed/share/pcl-1.8)

SET(Boost_NO_SYSTEM_PATHS ON)
SET(Boost_INCLUDE_DIR /home/yake/Downloads/boost_1_61_0/yake_boost161_installed/include)
SET(Boost_LIBRARY_DIR /home/yake/Downloads/boost_1_61_0/yake_boost161_installed/lib)

include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIR})

find_package(Boost 1.61.0 EXACT REQUIRED)
message("------------------------------- Boost VERSION = ${Boost_VERSION}")
message("------------------------------- Boost Include path = ${Boost_INCLUDE_DIRS}")
message("------------------------------- Boost LIBRARY_DIRS = ${Boost_LIBRARY_DIRS}")
message("------------------------------- Boost LIBRARIES = ${Boost_LIBRARIES}\n")

find_package(PCL 1.8 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

add_executable(xtion_instric_param src/xtion_instric_param.cpp)
target_link_libraries(xtion_instric_param ${Boost_LIBRARIES} ${PCL_LIBRARIES} )

add_executable(xtion_openni2_topic src/xtion_openni2_topic.cpp)
target_link_libraries(xtion_openni2_topic ${Boost_LIBRARIES} ${PCL_LIBRARIES} )

对于PCL来说,它安装以后会在share目录下生成一个PCLConfig.cmake的文件,和opencv一样,只要利用SET(PCL_DIR /home/yake)这句指向那里就可以了也和opencv调用一样。

boost这里有点不同,因为使用的boost自带的编译工具b2编译的,它安装以后只有lib和include文件夹。

https://stackoverflow.com/questions/3897839/how-to-link-c-program-with-boost-using-cmake

上面的CMakeLists.txt的写法是参考这里的回答,可以起作用。

利用ldd命令查看链接的文件

另外的两篇关于CMakeLists.txt的文章,我觉得有这三篇一般的CMakeList.txt的问题都可以解决了

猜你喜欢

转载自blog.csdn.net/yaked/article/details/80761976