如何修复 Ubuntu 上的 CMake 'Could not find a package configuration file provided by "VTK"'

问题:

当尝试编译你的 CMake 项目时,你会看到类似这样的错误消息

vtk_error.txt
CMake Error at cMake/FreeCAD_Helpers/SetupSalomeSMESH.cmake:29 (find_package):
  Could not find a package configuration file provided by "VTK" with any of
  the following names:

    VTKConfig.cmake
    vtk-config.cmake

  Add the installation prefix of "VTK" to CMAKE_PREFIX_PATH or set "VTK_DIR"
  to a directory containing one of the above files.  If "VTK" provides a
  separate development package or SDK, be sure it has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:71 (SetupSalomeSMESH)

解决方案

install_libvtk9_dev.sh
sudo apt -y install libvtk9-dev

注意,根据你使用的 Ubuntu 版本,你可能需要使用略有不同的 vtk 版本(9)。libvtk9-dev 适用于 Ubuntu 22.04


Check out similar posts by category: CMake, Linux