cmake build_error ai_generated true

CMake Error: No CMAKE_CXX_COMPILER could be found

ID: cmake/no-cxx-compiler-found

Also available as: JSON · Markdown
92%Fix Rate
90%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3 active

Root Cause

CMake cannot find a C/C++ compiler. Toolchain not installed or not in PATH.

generic

Workarounds

  1. 95% success Install the compiler toolchain
    sudo apt install build-essential

    Sources: https://cmake.org/cmake/help/latest/

  2. 85% success Use CMake toolchain file for cross-compilation
    cmake -DCMAKE_TOOLCHAIN_FILE=arm-toolchain.cmake ..
  3. 88% success Specify compiler explicitly
    cmake -DCMAKE_CXX_COMPILER=/usr/bin/g++-12 ..

Dead Ends

Common approaches that don't work:

  1. Set CMAKE_CXX_COMPILER to compiler include directory 82% fail

    Must point to compiler EXECUTABLE (e.g., /usr/bin/g++), not a directory

  2. Install cmake assuming it includes a compiler 88% fail

    CMake is a build system generator, not a compiler. You need gcc/g++ separately.