Це 1:12 ранку, і я втомився та розлючений. Нарешті я намагаюся вивчити cmake, але, звісно ж, це безумовно складно, і з’явилася проблема, з якою, здається, стикаюся тільки я. Помилка полягає у тому, що компілятор (який є g++) не може скомпілювати просту тестову програму, і через це cmake просто не збирається генерувати Makefile.
1 2 |
CMake Error at C:/mingw64/share/cmake-3.27/Modules/CMakeTestCXXCompiler.cmake:60 (message): The C++ compiler "C:/mingw64/bin/g++.exe" is not able to compile a simple test program. It fails with the following output: |
Ось CMakeLists.txt
, який я використовував:
1 2 3 4 5 6 7 |
cmake_minimum_required(VERSION 3.10) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_COMPILER g++) set(CMAKE_MAKE_PROGRAM make) project(out VERSION 1.0 LANGUAGES CXX) add_executable(out src/main.cpp) |
Команда, яку я використовував: cmake -S . -B build -G "MinGW Makefiles"
І повідомлення про помилку у цілому:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
-- The CXX compiler identification is GNU 13.2.0 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - failed -- Check for working CXX compiler: C:/mingw64/bin/g++.exe -- Check for working CXX compiler: C:/mingw64/bin/g++.exe - broken CMake Error at C:/mingw64/share/cmake-3.27/Modules/CMakeTestCXXCompiler.cmake:60 (message): The C++ compiler "C:/mingw64/bin/g++.exe" is not able to compile a simple test program. It fails with the following output: Change Dir: 'C:/Users/tyler/cpp_programs/learning_cmake/build/CMakeFiles/CMakeScratch/TryCompile-46pogc' Run Build Command(s): C:/mingw64/bin/cmake.exe -E env VERBOSE=1 "" -f Makefile cmTC_0793c/fast The parameter is incorrect CMake will not be able to correctly generate this project. Call Stack (most recent call first): CMakeLists.txt:9 (project) -- Configuring incomplete, errors occurred! |
Я не можу повірити, що просто створення звичайних Makefiles є простіше, ніж використання CMake. Це дійсно змушує задуматися, чому люди його використовують. Я дуже розлючений, знаєте? Здається, що я працюю з чорною скринькою, яка завжди несподівано викидає мені проблему, яку я не можу зрозуміти. Я просто хочу рішення.
Я використовую Windows 10, x86_64-w64-mingw32 і NeoVim.