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

devtools/2025/1/22 17:55:45/

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不支持这个报错


http://www.ppmy.cn/devtools/152651.html

相关文章

uni-app vue3 常用页面 组合式api方式

全局api请求封装 utils/request.js import config from /utils/config; // 统一 POST 请求方法示例 const post (url, data, options {}) > {url config.url url;console.log("uni.getStorageSync(token)", uni.getStorageSync(token));const defaultOptions…

ROS2测试仿真

电脑配置&#xff1a;R7-7840H 核显 结论&#xff1a;turtlebot3 运行失败。 turtlebot4 可以进入仿真环境&#xff0c;但是无法操作。 现在在用 ign gazebo 驱动简单的差分机器人 ign gazebo 采用ign gazebo 打开简单的差分机器人 安装 sudo apt-get install ros-${ROS_DI…

【HarmonyOS NAPI 深度探索12】创建你的第一个 HarmonyOS NAPI 模块

【HarmonyOS NAPI 深度探索12】创建你的第一个 HarmonyOS NAPI 模块 在本篇文章中&#xff0c;我们将一步步走过如何创建一个简单的 HarmonyOS NAPI 模块。通过这个模块&#xff0c;你将能够更好地理解 NAPI 的工作原理&#xff0c;并在你的应用中开始使用 C 与 JavaScript 的…

Elixir语言的语法

Elixir 语言简介与实践 1. 引言 在现代软件开发中&#xff0c;选择合适的编程语言对于项目的成功至关重要。Elixir作为一种功能强大的并发编程语言&#xff0c;近年来逐渐走入开发者的视野。本文将通过Elixir的基本语法、特性和实践案例&#xff0c;帮助读者深入了解这种语言…

MySQL篇之对MySQL进行参数优化,提高MySQL性能

1. MySQL参数优化说明 MySQL 参数调优是提高数据库性能的重要手段之一。通过调整 MySQL 的配置参数&#xff0c;可以优化查询速度、提升并发处理能力、减少资源消耗等。 MySQL 的性能优化涉及到多个方面&#xff0c;包括内存管理、磁盘 I/O、查询优化、连接管理、复制配置等。…

2.6 聚焦:Word Embedding

聚焦:Word Embedding Word Embedding(词嵌入) 是一种将词语转化为低维向量表示的技术,使得词语在数学空间中具有语义上的相似性。它是自然语言处理(NLP)中不可或缺的一部分,为文本数据提供了强大的表示能力。与传统的基于词频的词袋模型(Bag-of-Words)相比,Word Emb…

Java面试专题——面向对象

面向过程和面向对象的区别 面向过程&#xff1a;当事件比较简单的时候&#xff0c;利用面向过程&#xff0c;注重的是事件的具体的步骤/过程&#xff0c;注重的是过程中的具体的行为&#xff0c;以函数为最小单位&#xff0c;考虑怎么做。 面向对象&#xff1a;注重找“参与者…

leetcode215.数组中的第K个最大元素

标签&#xff1a;计数排序 给定整数数组 nums 和整数 k&#xff0c;请返回数组中第 k 个最大的元素。请注意&#xff0c;你需要找的是数组排序后的第 k 个最大的元素&#xff0c;而不是第 k 个不同的元素。你必须设计并实现时间复杂度为 O(n) 的算法解决此问题。 示例 1: 输…