Ubuntu20.04 pcl1.8编译报错[The `PATH` argument is required.]

在尝试构建pcl-pcl-1.8.0时遇到了CMake错误,具体表现为在检查模块和库时发现了一些版本,如metslib、ZLIB、PNG和QHULL,但在处理VTK时出现了问题。CMake检测到的CMake版本为3.20,更换为3.10后问题得到解决。错误源于`vtkDetectLibraryType.cmake`中缺少`PATH`参数。解决方案是从官方链接找到的,通过将CMake版本降低到3.10成功规避了错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

报错代码如下:

-- Checking for module 'metslib'
--   Found metslib, version 0.5.3
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11") 
-- Found PNG: /usr/lib/x86_64-linux-gnu/libpng.so (found version "1.6.37") 
-- Found Qhull: /usr/lib/x86_64-linux-gnu/libqhull.so  
-- QHULL found (include: /usr/include, lib: optimized;/usr/lib/x86_64-linux-gnu/libqhull.so;debug;/usr/lib/x86_64-linux-gnu/libqhull.so)
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found CUDA Toolkit v11.1
-- CUDA NVCC target flags: -gencode;arch=compute_20,code=sm_20;-gencode;arch=compute_20,code=sm_21;-gencode;arch=compute_30,code=sm_30;-gencode;arch=compute_35,code=sm_35;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_52,code=sm_52
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so  found components: OpenGL GLX 
CMake Error at /usr/local/lib/cmake/vtk-9.2/vtkDetectLibraryType.cmake:23 (message):
  The `PATH` argument is required.
Call Stack (most recent call first):
  /usr/local/lib/cmake/vtk-9.2/FindFreetype.cmake:179 (vtk_detect_library_type)
  /usr/local/lib/cmake/vtk-9.2/patches/3.19/FindX11.cmake:235 (find_package)
  /usr/local/lib/cmake/vtk-9.2/VTK-vtk-module-find-packages.cmake:350 (find_package)
  /usr/local/lib/cmake/vtk-9.2/vtk-config.cmake:152 (include)
  CMakeLists.txt:362 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/yg/pcl-pcl-1.8.0/build/CMakeFiles/CMakeOutput.log".
See also "/home/yg/pcl-pcl-1.8.0/build/CMakeFiles/CMakeError.log".

原因是我的CMake是3.20 ,换成了CMake3.10之后就好了。
解决方法来源:
https://github.com/AvtechScientific/ASL/issues/48
CMake降级方法:
Cmake降级

### Ubuntu 20.04 上安装 PCL 1.8 对于希望在Ubuntu 20.04上安装特定版本的PCL(如1.8版),可以采用两种主要的方法:通过包管理器安装预编译二进制文件或从源码构建。考虑到用户遇到`make`文件错误的情况,建议先尝试简单快捷的方式——利用APT仓库进行安装。 #### 方法一:使用 APT 安装 PCL 1.8 尽管默认情况下Ubuntu 20.04可能提供更新版本的PCL,但可以通过添加旧版本软件源来获取并安装PCL 1.8: ```bash sudo add-apt-repository ppa:v-launchpad-jochen-sprickerhof-de/pcl sudo apt-get update sudo apt-get install libpcl1.8 pcl-tools ``` 此方法能够简化依赖关系处理,并减少因手动配置而引发的问题[^1]。 如果上述PPA不再维护所需版本,则需考虑更复杂的方案即从源码编译安装。 #### 方法二:从源码安装 PCL 1.8 当需要精确控制所安装的具体版本时,下载对应标签下的源代码是最可靠的选择之一。以下是具体操作流程: 1. **准备开发环境** 需要确保系统已准备好必要的工具链以及依赖项: ```bash sudo apt-get install build-essential cmake git pkg-config ``` 2. **克隆指定版本的PCL仓库** 使用Git检出目标分支或打标签对应的提交点: ```bash git clone https://github.com/PointCloudLibrary/pcl.git -b pcl-1.8 cd pcl ``` 3. **创建构建目录并执行 CMake** 推荐在一个独立于源码树之外的新建子目录内完成编译过程: ```bash mkdir build && cd build cmake .. ``` 4. **调整CMake选项(可选)** 如果之前遇到了Boost相关联结问题,可以在调用cmake前设置环境变量以指向正确的路径;或者直接修改CMake参数排除不必要的组件支持: ```bash export BOOST_ROOT=/path/to/your/boost/installation cmake .. -DBUILD_visualization=OFF -DBUILD_outofcore=OFF ``` 5. **编译项目** 执行实际编译工作: ```bash make -j$(nproc) ``` 6. **安装至系统** 将生成的目标文件复制到适当位置以便全局访问: ```bash sudo make install ``` 7. **验证安装成功与否** 可以编写简单的测试程序确认API可用性: ```cpp #include <iostream> #include <pcl/io/pcd_io.h> #include <pcl/point_types.h> int main(int argc, char** argv){ pcl::PointXYZ point; std::cout << "Point X: " << point.x << ", Y: " << point.y << ", Z:" << point.z << std::endl; } ``` 编译该示例代码片段并将结果链接到新安装的库中: ```bash g++ test_pcl.cpp -o test_pcl `pkg-config --cflags --libs pcl_common` ./test_pcl ``` 以上步骤有助于解决由不同版本间兼容性差异引起的各种潜在难题[^3]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

高哥的代码没Bug

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值