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

构建ROOT项目遇CMake错误:需采用源码外构建方式求助

Fixing "ROOT should be built as an out of source build" Error

Hey there, let's get this ROOT build sorted out quickly! That error is telling you exactly what's wrong: ROOT requires an out-of-source build, which means you can't run cmake in a way that mixes your source code files with build-generated artifacts.

Step-by-step fix to get your build working:

First, let's set up a clean build structure separate from your ROOT source code:

  • Navigate to the parent folder of your ROOT source directory (I’ll assume your source lives in a folder named root).
  • Create a dedicated build directory (this keeps all compiled files, logs, and intermediate outputs away from your clean source code):
    mkdir root-build
    
  • Move into this new build directory:
    cd root-build
    
  • Now run cmake pointing to your ROOT source folder:
    cmake ../root
    
  • Once CMake completes without errors, you can start building ROOT with:
    make -j$(sysctl -n hw.ncpu)  # Uses all your Mac's CPU cores for faster builds
    

Why this matters:

Out-of-source builds are a standard best practice for large CMake projects like ROOT. They:

  • Keep your source directory completely clean (no generated files cluttering up your code)
  • Let you create multiple build directories for different configurations (e.g., one for debug builds, one for optimized releases) without overlapping files
  • Make it trivial to start fresh if something goes wrong—just delete the build directory and start over!

Your original error output for reference:

Harshits-Air:root harshitprasad$ cmake ../root
-- Found a Mac OS X System 10.13
-- Found a 64bit system
-- Found LLVM compiler collection
-- ROOT Platform: macosx
-- ROOT Architecture: macosx64
-- Build Type: RelWithDebInfo
-- Compiler Flags: -Wc++11-narrowing -Wsign-compare -Wsometimes-uninitialized -Wconditional-uninitialized -Wheader-guard -Warra
CMake error: ROOT should be built as an out of source build

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 10:18:40