You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WSL下编译PCL库时CMake报错问题求助

PCL库编译问题排查与解决

问题背景

在WSL环境下编译新安装的PCL库,已按相关步骤安装所有提及的依赖,但仍出现编译配置错误。

错误信息

CMake Deprecation Warning at CMakeLists.txt:15 (cmake_policy):
The OLD behavior for policy CMP0048 will be removed from a futur 
version of CMake.l/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)
The cmake-policies(7) manual explains that the OLD behaviors of al 
(find_package) policies are deprecated and that a policy should be set to OLD only under specific short-term circumstances.  
Projects should be ported to the NEW behavior and not rely on setting a policy to OLD.

The cmake-policies(7) manual explains that the OLD behaviors of all 
policies are deprecated and that a policy should be set to OLD only 
under specific short-term circumstances.  

--Could NOT find LIBUSB_1 (missing: LIBUSB_1_LIBRARY LIBUSB_1_INCLUDE_DIR)
-- Checking for module 'metslib'
-- No package 'metslib' found
-- Configuring incomplete, errors occurred!
-- QHULL found (include: /usr/include, lib: 
   optimized;/usr/lib/x86_64-linux gnu/libqhull.so;debug;/usr/lib/x86_64-linux-gnu/libqhull.so)
   CMake Error at /usr/local/lib/cmake/vtk 9.2/vtkDetectLibraryType.cmake:23 (message):
   The `PATH` argument is required.
    
   Projects should be ported to the NEW behavior and not rely on 
   setting a policy to OLD.

问题分析与解决步骤

1. CMP0048警告说明

这个警告确实和CMake版本相关。CMP0048是CMake的策略规则,用于控制project()命令的版本处理逻辑:

  • OLD行为允许project()命令不指定版本或使用宽松的版本格式;
  • NEW行为要求严格遵循版本格式规范,同时会自动设置相关版本变量。

注意:该警告不是编译失败的直接原因,仅提示当前CMakeLists.txt使用了即将被移除的旧行为,真正导致配置失败的是后续的依赖缺失和VTK兼容性问题。

2. 缺失LIBUSB_1依赖

执行以下命令安装对应的开发包:

sudo apt-get update && sudo apt-get install libusb-1.0-0-dev

3. 缺失metslib依赖

metslib是PCL部分模块依赖的优化库,安装命令:

sudo apt-get install libmetslib-dev

4. VTK版本兼容性错误

错误提示VTK的vtkDetectLibraryType.cmake文件缺少PATH参数,原因是手动安装的VTK 9.2与PCL的CMake配置不兼容。解决方式:

  • 卸载手动编译的VTK,改用Ubuntu官方源提供的兼容版本:
sudo apt-get remove libvtk9-dev # 若之前安装过官方包先卸载
sudo rm -rf /usr/local/lib/cmake/vtk-9.2 # 删除手动安装的VTK配置文件
sudo apt-get install libvtk9-dev

重新编译

完成上述步骤后,删除原有的build目录,重新执行CMake配置和编译:

rm -rf build && mkdir build && cd build
cmake ..
make -j$(nproc)

内容的提问来源于stack exchange,提问作者Ken Adams

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.04 01:40:22