Build Fails on Windows 10: CMake Cannot Locate `clang` / `clang++` Compiler
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 52/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Lĩnh vực
- build-system
Hướng nghiên cứu
Bắt đầu trong setup_env.py và kiểm tra OS_EXTRA_ARGS của Windows cùng các đối số trình biên dịch CMake, sau đó xem lại CMakeLists.txt và tái hiện bằng python setup_env.py -md models/BitNet-b1.58-2B-4T -q i2_s. Hoàn tất khi CMake xác định được trình biên dịch C/C++ của Windows và quá trình build hoàn thành vượt qua bước cấu hình mà không yêu cầu các đường dẫn clang hoặc clang++ không khả dụng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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:
- ClangCL is not installed or not properly configured.
clang/clang++are not present in the systemPATH, 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 ClangCLoption 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=clangand-DCMAKE_CXX_COMPILER=clang++flags forced CMake to look for Clang inPATH, which was not available.Removing these flags allows CMake to auto-detect the default compiler provided by the MinGW Makefiles generator.
- Ngôn ngữ chính
- C++
- Star
- 40.3k
- Fork
- 3.7k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/BitNet
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
-
i2_s SIGSEGVs at n_ubatch >= 32: BLAS backend dequantises by a row stride 4x the real packed row Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Tất cả issue của microsoft/BitNet
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
duckdb/duckdb-wasm#2258 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
objectionary/eo-graphs#75 ·
-
Coarray integration tests carry no LABELS, so run_tests.py silently skips them under every backend Đang mởcoarray
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
FISCO-BCOS/FISCO-BCOS#5642 ·