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

编译CMake 3.10.2源码时因缺失gl/gl.h配置失败,如何取消依赖?

Fixing CMake 3.10.2 Build Failure Due to Missing gl/gl.h

Hey there, let's work through this issue with compiling CMake 3.10.2. The gl/gl.h error pops up because CMake tries to build its Qt-based GUI tools (like cmake-gui) which require OpenGL dependencies. Since you don't have a GL environment set up and likely just need the core command-line CMake functionality, you can disable these GUI components entirely to skip the GL dependency.

Here's how to do it step by step:

  1. Prepare your build directory (always a good practice to keep your source tree clean):

    mkdir build && cd build
    
  2. Run CMake configuration with GUI-disabling flags
    Use your existing older CMake version to configure the build, adding these critical flags to cut out GL-dependent components:

    cmake ../path/to/cmake-3.10.2-source \
      -DCMAKE_BUILD_TYPE=Release \
      -DBUILD_QtDialog=OFF \
      -DCMAKE_DISABLE_FIND_PACKAGE_OpenGL=ON \
      -DBUILD_CursesDialog=OFF
    

Let's break down what each flag does:

  • -DBUILD_QtDialog=OFF: This directly disables the Qt-based cmake-gui tool, which is the main source of the OpenGL dependency.
  • -DCMAKE_DISABLE_FIND_PACKAGE_OpenGL=ON: Forces CMake to skip all attempts to locate OpenGL headers or libraries, eliminating any related checks entirely.
  • -DBUILD_CursesDialog=OFF: Optional, but disables the ncurses-based terminal GUI if you don't need it (this doesn't rely on GL, but removing it keeps the build focused on core command-line tools).
  • -DCMAKE_BUILD_TYPE=Release: Compiles optimized, release-ready binaries instead of debug builds to save resources.
  1. Compile and install
    Once the configuration completes without errors, proceed to compile and install the new CMake version:
    make -j$(nproc)
    sudo make install
    

This setup will only build the core command-line tools (cmake, ctest, cpack) and skip all GUI components that require OpenGL. Since you're using your existing CMake to bootstrap the new version, you don't have to worry about missing additional build tools beyond what you already have.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 07:30:11