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

Ubuntu22.04编译Orthanc时CHECK_INCLUDE_FILE_CXX找不到pugixml头文件

Ubuntu 22.04编译Orthanc时pugixml头文件检测失败问题

问题概述

在Ubuntu 22.04上编译医学影像项目Orthanc时,CMake的CHECK_INCLUDE_FILE_CXX无法检测到已安装的pugixml头文件,尽管已通过apt-get安装pugixml并将库文件放置到/usr/lib/目录下。且无法修改项目代码,需解决该检测问题。

环境信息

  • 操作系统:Ubuntu 22.04
  • CMake版本:3.27.0
  • 编译命令:
cmake -DCMAKE_BUILD_TYPE=Release -DUSE_SYSTEM_CIVETWEB=OFF -DALLOW_DOWNLOADS=ON path/to/Orthanc/orthanc/OrthancServer

已执行操作

  • 通过apt-get安装pugixml
  • 将pugixml库文件复制到/usr/lib/目录

项目相关CMake代码

pugixml检测逻辑

CHECK_INCLUDE_FILE_CXX(pugixml.hpp HAVE_PUGIXML_H)
if (NOT HAVE_PUGIXML_H)
  message(FATAL_ERROR "Please install the libpugixml-dev package")
endif()

link_libraries(pugixml)

项目加载的CMake模块

include(CMakePushCheckState)
include(CheckFunctionExists)
include(CheckIncludeFile)
include(CheckIncludeFileCXX)
include(CheckIncludeFiles)
include(CheckLibraryExists)
include(CheckStructHasMember)
include(CheckSymbolExists)
include(CheckTypeSize)
include(FindPythonInterp)

项目CMake版本设置

cmake_minimum_required(VERSION 2.8)
cmake_policy(SET CMP0058 NEW)

cmake --fresh完整日志

CMake Deprecation Warning at CMakeLists.txt:21 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning (dev) at /home/ypollet/Numerisation/Orthanc/orthanc/OrthancFramework/Resources/CMake/OrthancFrameworkConfiguration.cmake:46 (include):
  Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
  are removed.  Run "cmake --help-policy CMP0148" for policy details.  Use
  the cmake_policy command to set the policy and suppress this warning.

Call Stack (most recent call first):
  CMakeLists.txt:79 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found PythonInterp: /usr/bin/python3.10 (found version "3.10.12") 
-- Looking for sqlite3.h
-- Looking for sqlite3.h - found
SQLite include dir: /usr/include
Detected version of SQLite: 3037002
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "3.0.2")  
-- Found CURL: /usr/lib/x86_64-linux-gnu/libcurl.so (found version "7.81.0")  
-- Looking for C++ include civetweb.h
-- Looking for C++ include civetweb.h - not found
CMake Error at /home/ypollet/Numerisation/Orthanc/orthanc/OrthancFramework/Resources/CMake/CivetwebConfiguration.cmake:108 (message):
  Please install the libcivetweb-dev package
Call Stack (most recent call first):
  /home/ypollet/Numerisation/Orthanc/orthanc/OrthancFramework/Resources/CMake/OrthancFrameworkConfiguration.cmake:306 (include)
  CMakeLists.txt:79 (include)


-- Configuring incomplete, errors occurred!

解决方案

  1. 确认安装libpugixml-dev包
    普通pugixml包不包含头文件,必须安装开发包:

    sudo apt-get install libpugixml-dev
    
  2. 验证头文件路径
    检查pugixml.hpp是否存在于系统默认包含目录:

    ls /usr/include/pugixml.hpp
    

    若存在则继续下一步,若不存在需确认包安装是否完整。

  3. 强制指定包含路径
    若头文件存在但CMake仍检测不到,通过环境变量指定包含目录后重新编译:

    export CXXFLAGS="-I/usr/include"
    cmake --fresh -DCMAKE_BUILD_TYPE=Release -DUSE_SYSTEM_CIVETWEB=OFF -DALLOW_DOWNLOADS=ON path/to/Orthanc/orthanc/OrthancServer
    
  4. 处理civetweb相关错误
    日志中出现civetweb头文件未找到的错误,尽管设置了USE_SYSTEM_CIVETWEB=OFF和ALLOW_DOWNLOADS=ON,可能是网络问题导致自动下载失败。可手动下载civetweb源码放置到项目指定的依赖目录,或检查网络连接后重新执行CMake命令。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.06 17:17:51