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

执行cmake ..时无法找到PugiXml配置文件,安装libpugixml-dev无效求解决

解决CMake找不到PugiXml配置文件的问题

执行cmake ..时出现如下错误:

Could not find a package configuration file provided by "PugiXml" with any
of the following names:

PugiXmlConfig.cmake
pugixml-config.cmake

Add the installation prefix of "PugiXml" to CMAKE_PREFIX_PATH or set
"PugiXml_DIR" to a directory containing one of the above files. If
"PugiXml" provides a separate development package or SDK, be sure it has
been installed.

已通过sudo apt install libpugixml-dev安装开发包但问题未解决,可尝试以下方案:

  • 手动指定配置文件路径
    先查找系统中已安装的pugixml配置文件位置:

    find /usr -name "pugixml-config.cmake" -o -name "PugiXmlConfig.cmake"
    

    找到路径后,在执行cmake时指定PugiXml_DIR:

    cmake .. -DPugiXml_DIR=/path/to/pugixml/cmake/directory
    

    或者将配置文件所在的父目录添加到CMAKE_PREFIX_PATH:

    cmake .. -DCMAKE_PREFIX_PATH=/path/to/pugixml/parent/directory
    
  • 从源码编译安装PugiXml
    若apt包未提供正确的CMake配置文件,直接源码编译安装:

    1. 克隆源码:
      git clone https://github.com/zeux/pugixml.git
      cd pugixml
      
    2. 编译安装:
      mkdir build && cd build
      cmake .. -DBUILD_SHARED_LIBS=ON
      make -j$(nproc)
      sudo make install
      

    安装完成后,CMake默认会在/usr/local/lib/cmake/pugixml/找到配置文件。

  • 调整项目CMakeLists.txt
    检查项目中的find_package调用,若原代码是find_package(PugiXml),尝试改为小写的find_package(pugixml),匹配apt安装的配置文件名。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.25 13:54:21