Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Build Fails on Windows 10: CMake Cannot Locate `clang` / `clang++` Compiler

オープン
#554 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
52/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
cmake, cpp, python
領域
build-system

調査の方向性

setup_env.py から始めて、Windows の OS_EXTRA_ARGS と CMake コンパイラ引数を確認し、その後 CMakeLists.txt を調べて、python setup_env.py -md models/BitNet-b1.58-2B-4T -q i2_s で再現します。CMake が Windows の C/C++ コンパイラを見つけ、利用できない clang または clang++ のパスを必要とせずに、ビルドが構成以降まで完了すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Environment

  • OS: Windows 10
  • Command: python setup_env.py -md models/BitNet-b1.58-2B-4T -q i2_s

Problem

When running the setup script, CMake fails to identify and locate the C/C++ compilers (clang / clang++). The build does not proceed beyond the configuration phase.

I also referenced #513 for potential solutions, but the suggestions there did not resolve the issue in my environment.

Error Output
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown

CMake Error at CMakeLists.txt:2 (project):
  The CMAKE_C_COMPILER:
    clang
  is not a full path and was not found in the PATH.  Perhaps the extension is
  missing?
  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.

CMake Error at CMakeLists.txt:2 (project):
  The CMAKE_CXX_COMPILER:
    clang++
  is not a full path and was not found in the PATH.  Perhaps the extension is
  missing?
  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.

-- Configuring incomplete, errors occurred!
Root Cause

The script attempts to use the ClangCL toolset on Windows with explicitly set clang / clang++ compilers. However, on some Windows environments:

  1. ClangCL is not installed or not properly configured.
  2. clang / clang++ are not present in the system PATH, causing CMake to fail.

Solution

I made two modifications in setup_env.py, after which the build completed successfully.

Change 1: Switch CMake Generator from ClangCL to MinGW Makefiles

Original:

OS_EXTRA_ARGS = {
    "Windows": ["-T", "ClangCL"],
}

Modified:

OS_EXTRA_ARGS = {
    "Windows": ["-G", "MinGW Makefiles"],
}

The -T ClangCL option requires a specific Clang installation that is compatible with MSVC. If this toolchain is not properly set up, CMake cannot locate the compiler.

Switching to MinGW Makefiles allows CMake to use the default system compiler (typically gcc/g++ from MinGW) without requiring ClangCL.

Change 2: Remove Explicit clang / clang++ Compiler Specification

Original:

run_command([
    "cmake", "-B", "build",
    _COMPILER_EXTRA_ARGS[arch],
    OS_EXTRA_ARGS.get(platform.system(), []),
    "-DCMAKE_C_COMPILER=clang",
    "-DCMAKE_CXX_COMPILER=clang++"
], log_step="generate_build_files")

Modified:

run_command([
    "cmake", "-B", "build",
    _COMPILER_EXTRA_ARGS[arch],
    OS_EXTRA_ARGS.get(platform.system(), [])
], log_step="generate_build_files")

The -DCMAKE_C_COMPILER=clang and -DCMAKE_CXX_COMPILER=clang++ flags forced CMake to look for Clang in PATH, which was not available.

Removing these flags allows CMake to auto-detect the default compiler provided by the MinGW Makefiles generator.

主要言語
C++
スター
40.3k
フォーク
3.7k
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/BitNet のほかの issue

microsoft/BitNet の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。