从零开始解决ubuntu2204,pcl-1.8 编译中报错的问题,cmake-gui编译

1.编译pcl时候报错,

kdtree is required, but flann not found

2.然后下载了flann,编译flann是报错

按照步骤编译的时候会报错,错误如下:

CMake Eroor at src/cpp/CMakeLists.txt:86 (add_library):

No SOURCES given to target: flann

CMake Eroor at src/cpp/CMakeLists.txt:32 (add_library):

No SOURCES given to target: flann_cpp

直到看到这个网页

https://stackoverflow.com/questions/50763621/building-flann-with-cmake-fails

直到原来是本身的问题,按照里面写的修改方法,先创建一个空的文件,然后加入到库中就行了,具体是:

首先

touch src/cpp/empty.cpp

然后在src/cpp/CMakeLists.txt中将

add_library(flann_cpp SHARED "") and add_library(flann SHARED "")

代替为

add_library(flann_cpp SHARED empty.cpp) and add_library(flann SHARED empty.cpp)

2.编译boost,官网直接下,下载下来直接编译:

① sudo ./bootstrap.sh --prefix=/home/lib

② sudo ./b2 install cxxflags="-std=c++14"

直接按照上面位置命令编译,正常情况下会编译通过,直接生成库,但是在编译pcl时发现问题(问题后面说),pcl编译不过然后倒回来发现boost编译时有问题,却库,缺iosstream.so这个库,查编译过程发现,编译中有报错:fatal error: bzlib.h: No such file or directory,解决报错问题:

sudo apt-get install libbz2-dev

安装完libbz后在编译,按照①②步骤重新编一编发现一切正常,会生成iosstream.so,boost编译完成。

3.编译pcl,用camke_gui编译(有点坑,不会提示boost相关的东西),直接编会报错:Could NOT find Boost (missing: iostreams)(就是上面提到的错),此时需要人为手动配置boost路径,打开pcl/cmake/pcl_find_boost.cmake这个文件,然后在里面添加boost和版本号,

set(Boost_LIBRARY_DIR /*/boost_1_61_0/boost_1_61/lib)

set(Boost_INCLUDE_DIR /*/boost_1_61_0/boost_1_61/include)

增加上面两句后保存,然后再编译,

编译过程中报错:*/pcl-pcl-1.8.0/filters/src/frustum_culling.cpp:44:1: required from here

/usr/include/eigen3/Eigen/src/Core/Dot.h:75:3: error: static assertion failed: YOU_TRIED_CALLING_A_VECTOR_METHOD_ON_A_MATRIX

75 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)

| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

查了半天发现是pcl-1.8自己的问题,不过这个问题在,pcl-1.10以后被修改了,可以参考github的上的解释:https://github.com/PointCloudLibrary/pcl/pull/2786/commits/3eeca19fda82a6d393f3c6bd09d2331ad60ee53c

错误一 针对pcl1.8所报错误,修改如下:找到:pcl-1.8/filters/include/pcl/filters/impl/frustum_culling.hpp,打开后将原来的:(0,0,3,1)改成<3,1>(0,0),其他以此类推:将所有的(i,j,3,1)改成<3,1>(i,j),切记这个文件里的所有的都要改。具体如下:

Eigen::Vector3f view = camera_pose_.block <3, 1> (0, 0);//(0, 0, 3, 1); // view vector for the camera - first column of the rotation matrix

Eigen::Vector3f up = camera_pose_.block <3, 1> (0, 1);//(0, 1, 3, 1); // up vector for the camera - second column of the rotation matix

Eigen::Vector3f right = camera_pose_.block <3, 1> (0, 2);//(0, 2, 3, 1); // right vector for the camera - third column of the rotation matrix

Eigen::Vector3f T = camera_pose_.block <3, 1> (0, 3);//(0, 3, 3, 1); // The (X, Y, Z) position of the camera w.r.t origin

错误二 针对对编译报错类型不匹配问题:/pcl-pcl-1.8.0/segmentation/include/pcl/segmentation/plane_coefficient_comparator.h:144:17: error: invalid initialization of reference of type 'std::vector<float>&' from expression of type 'const boost::shared_ptr<std::vector<float> >'

144 | return (plane_coeff_d_);

找到文件plane_coefficient_comparator.h,做如下修改:

//const std::vector<float>&

boost::shared_ptr<std::vector<float>> getPlaneCoeffD () const

{

return (plane_coeff_d_);

}

将const std::vector<float>&改为boost::shared_ptr<std::vector<float>>或者

将 return (plane_coeff_d_);改为 return (*plane_coeff_d_);都可以

错误三 /pcl-pcl-1.8.0/surface/include/pcl/surface/impl/bilateral_upsampling.hpp:121:51: error: cannot convert 'Eigen::internal::enable_if<true, Eigen::IndexedView<Eigen::Matrix<float, -1, 1>, float, Eigen::internal::SingleRange> >::type' {aka 'Eigen::IndexedView<Eigen::Matrix<float, -1, 1>, float, Eigen::internal::SingleRange>'} to 'float' in initialization 121 |

float val_exp_rgb = val_exp_rgb_vector(d_color); | ~~~~~~~~~~~~~~~~~~^~~~~~~~~ | | | Eigen::internal::enable_if<true, Eigen::IndexedView<Eigen::Matrix<float, -1, 1>, float, Eigen::internal::SingleRange> >::type {aka Eigen::IndexedView<Eigen::Matrix<float, -1, 1>, float, Eigen::internal::SingleRange>}

将float val_exp_rgb = val_exp_rgb_vector(d_color);

改为float val_exp_rgb = val_exp_rgb_vector(int(d_color));

错误四: /usr/bin/ld: ../../lib/libpcl_kdtree.so.1.8.1: undefined reference to `LZ4_resetStreamHC'

/usr/bin/ld: ../../lib/libpcl_kdtree.so.1.8.1: undefined reference to `LZ4_setStreamDecode'

/usr/bin/ld: ../../lib/libpcl_kdtree.so.1.8.1: undefined reference to `LZ4_decompress_safe'

/usr/bin/ld: ../../lib/libpcl_kdtree.so.1.8.1: undefined reference to `LZ4_decompress_safe_continue'

/usr/bin/ld: ../../lib/libpcl_kdtree.so.1.8.1: undefined reference to `LZ4_compress_HC_continue'

collect2: error: ld returned 1 exit status

make[2]: *** [visualization/tools/CMakeFiles/pcl_viewer.dir/build.make:236: bin/pcl_viewer] Error 1

make[1]: *** [CMakeFiles/Makefile2:1631: visualization/tools/CMakeFiles/pcl_viewer.dir/all] Error 2

解决:/pcl/build/kdtree/CMakeFiles/pcl_kdtree.dir/下的link.txt里在末尾写上:-llz4

错误五 : /home/zc/Documents/pcl-pcl-1.8.1/recognition/include/pcl/recognition/3rdparty/metslib/local-search.hh:83:7: error: ISO C++17 does not allow dynamic exception specifications

83 | throw(no_moves_error);

| ^~~~~

/home/zc/Documents/pcl-pcl-1.8.1/recognition/include/pcl/recognition/3rdparty/metslib/local-search.hh:110:3: error: ISO C++17 does not allow dynamic exception specifications

110 | throw(no_moves_error)

| ^~~~~

In file included from /home/zc/Documents/pcl-pcl-1.8.1/recognition/include/pcl/recognition/3rdparty/metslib/mets.hh:150,

from /home/zc/Documents/pcl-pcl-1.8.1/recognition/include/pcl/recognition/hv/hv_go.h:14,

from /home/zc/Documents/pcl-pcl-1.8.1/recognition/include/pcl/recognition/impl/hv/hv_go.hpp:40,

from /home/zc/Documents/pcl-pcl-1.8.1/recognition/src/hv/hv_go.cpp:37:

/home/zc/Documents/pcl-pcl-1.8.1/recognition/include/pcl/recognition/3rdparty/metslib/tabu-search.hh:245:7: error: ISO C++17 does not allow dynamic exception specifications

245 | throw(no_moves_error);

| ^~~~~

/home/zc/Documents/pcl-pcl-1.8.1/recognition/include/pcl/recognition/3rdparty/metslib/tabu-search.hh:404:3: error: ISO C++17 does not allow dynamic exception specifications

404 | throw(no_moves_error)

| ^~~~~

In file included from /home/zc/Documents/pcl-pcl-1.8.1/recognition/include/pcl/recognition/3rdparty/metslib/mets.hh:151,

from /home/zc/Documents/pcl-pcl-1.8.1/recognition/include/pcl/recognition/hv/hv_go.h:14,

from /home/zc/Documents/pcl-pcl-1.8.1/recognition/include/pcl/recognition/impl/hv/hv_go.hpp:40,

from /home/zc/Documents/pcl-pcl-1.8.1/recognition/src/hv/hv_go.cpp:37:

/home/zc/Documents/pcl-pcl-1.8.1/recognition/include/pcl/recognition/3rdparty/metslib/simulated-annealing.hh:125:7: error: ISO C++17 does not allow dynamic exception specifications

125 | throw(no_moves_error);

| ^~~~~

/home/zc/Documents/pcl-pcl-1.8.1/recognition/include/pcl/recognition/3rdparty/metslib/simulated-annealing.hh:224:3: error: ISO C++17 does not allow dynamic exception specifications

224 | throw(no_moves_error)

解决办法:注释掉throw(no_moves_error)即可,由于c++17不支持这个报错

相关推荐
2303_Alpha5 小时前
SpringBoot
笔记·学习
萘柰奈5 小时前
Unity学习----【进阶】TextMeshPro学习(三)--进阶知识点(TMP基础设置,材质球相关,两个辅助工具类)
学习·unity
沐矢羽5 小时前
Tomcat PUT方法任意写文件漏洞学习
学习·tomcat
好奇龙猫5 小时前
日语学习-日语知识点小记-进阶-JLPT-N1阶段蓝宝书,共120语法(10):91-100语法+考え方13
学习
向阳花开_miemie6 小时前
Android音频学习(十八)——混音流程
学习·音视频
工大一只猿6 小时前
51单片机学习
嵌入式硬件·学习·51单片机
c0d1ng6 小时前
量子计算学习(第十四周周报)
学习·量子计算
Hello_Embed13 小时前
STM32HAL 快速入门(二十):UART 中断改进 —— 环形缓冲区解决数据丢失
笔记·stm32·单片机·学习·嵌入式软件
咸甜适中14 小时前
rust语言 (1.88) 学习笔记:客户端和服务器端同在一个项目中
笔记·学习·rust
Magnetic_h15 小时前
【iOS】设计模式复习
笔记·学习·ios·设计模式·objective-c·cocoa