问题起因:
在编译自己的相机SDK开发脚本时,报了类似如下的错误:
CMakeFiles/xag_nav_map_display.dir/src/pcl/pointcloud_io.cc.o: In function `pcl::PCDWriter::write(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, pcl::PCLPointCloud2 const&, Eigen::Matrix<float, 4, 1, 0, 4, 1> const&, Eigen::Quaternion<float, 0> const&, bool)': /usr/include/pcl-1.7/pcl/io/pcd_io.h:351: undefined reference to `pcl::PCDWriter::writeBinary(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, pcl::PCLPointCloud2 const&, Eigen::Matrix<float, 4, 1, 0, 4, 1> const&, Eigen::Quaternion<float, 0> const&)' /usr/include/pcl-1.7/pcl/io/pcd_io.h:353: undefined reference to `pcl::PCDWriter::writeASCII(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, pcl::PCLPointCloud2 const&, Eigen::Matrix<float, 4, 1, 0, 4, 1> const&, Eigen::Quaternion<float, 0> const&, int)' CMakeFiles/xag_nav_map_display.dir/src/pcl/pointcloud_io.cc.o: In function `int pcl::PCDWriter::writeASCII<pcl::PointXYZ>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, pcl::PointCloud<pcl::PointXYZ> const&, int)': /usr/include/pcl-1.7/pcl/io/impl/pcd_io.hpp:486: undefined reference to `pcl::PCDWriter::setLockingPermissions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::interprocess::file_lock&)' /usr/include/pcl-1.7/pcl/io/impl/pcd_io.hpp:598: undefined reference to `pcl::console::print(pcl::console::VERBOSITY_LEVEL, char const*, ...)' /usr/include/pcl-1.7/pcl/io/impl/pcd_io.hpp:613: undefined reference to `pcl::PCDWriter::resetLockingPermissions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::interprocess::file_lock&)' CMakeFiles/xag_nav_map_display.dir/src/pcl/pointcloud_io.cc.o: In function `int pcl::PCDWriter::writeBinary<pcl::PointXYZ>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, pcl::PointCloud<pcl::PointXYZ> const&)': /usr/include/pcl-1.7/pcl/io/impl/pcd_io.hpp:157: undefined reference to `pcl::PCDWriter::setLockingPermissions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::interprocess::file_lock&)' /usr/include/pcl-1.7/pcl/io/impl/pcd_io.hpp:193: undefined reference to `pcl::PCDWriter::resetLockingPermissions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::interprocess::file_lock&)' /usr/include/pcl-1.7/pcl/io/impl/pcd_io.hpp:194: undefined reference to `pcl::console::print(pcl::console::VERBOSITY_LEVEL, char const*, ...)' /usr/include/pcl-1.7/pcl/io/impl/pcd_io.hpp:204: undefined reference to `pcl::PCDWriter::resetLockingPermissions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::interprocess::file_lock&)' /usr/include/pcl-1.7/pcl/io/impl/pcd_io.hpp:213: undefined reference to `pcl::PCDWriter::resetLockingPermissions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::interprocess::file_lock&)' /usr/include/pcl-1.7/pcl/io/impl/pcd_io.hpp:247: undefined reference to `pcl::PCDWriter::resetLockingPermissions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::interprocess::file_lock&)' /usr/include/pcl-1.7/pcl/io/impl/pcd_io.hpp:258: undefined reference to `pcl::PCDWriter::resetLockingPermissions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::interprocess::file_lock&)' collect2: error: ld returned 1 exit status
推测应该是PCL动态库链接的有问题
最后复盘的时候想到其实之前我应该是都将库安装在了Anaconda的base环境下,但是没安装opencv,base环境中有pcl1.12。
一开始就是害怕这些库出问题,结果为了编译这个脚本在系统中装PCL的时候还是忘了之前都是使用虚拟环境了,导致现在装在系统里乱七八糟。。。哎,只好重装PCL。
opencv 4.5.5
安装在了/home/tian/lib/opencv-4.5.5-install/下(考虑到多版本兼容问题)
vtk7.1.1
安装好后,后续在编译pcl过程中出现:
/usr/bin/ld: 找不到 -lvtkIOMPIImage
/usr/bin/ld: 找不到 -lvtkIOMPIParallel
/usr/bin/ld: 找不到 -lvtkFiltersParallelDIY2
解决方法:
在cmake-gui中搜索关键字并勾选做重新编译
最终安装在/usr/local/路径下!
pcl1.12
由于在cmake过程中提示了很多can not find问题,依次解决,不要忽视,对应着去安装它的依赖metslib-0.5.3、OpenNI1.x版本
将~/.bashrc中虚拟环境的路径禁了。现在可能打不开conda
提示warning:
将/anaconda3/lib中的一些.so文件移动到了Tian_archive文件中,anaconda中的pcl环境可能会出问题,到时候安装完再还原回去吧。
最终安装在/usr/local/路径下!