CMake编译器无法编译简单的测试程序
我正在尝试在 Windows 11 x64 上设置 cmake
。
我正在使用 MinGW Makefiles
和 make.exe
进行构建。我使用 Cygwin
安装了编译器和 make
。编译器是本机编译器。
我的 CMakeLists.txt 包含以下内容:
cmake_minimum_required(VERSION 3.20)
project(hello CXX)
add_executable(hello main.cpp)
在 build
目录中,我运行以下命令:cmake -G "MinGW Makefiles" -DCMAKE_MAKE_PROGRAM=make ..
我得到的输出:
-- The CXX compiler identification is GNU 11.2.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: C:/cygwin64/bin/g++.exe
-- Check for working CXX compiler: C:/cygwin64/bin/g++.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeTestCXXCompiler.cmake:62 (message):
The C++ compiler
"C:/cygwin64/bin/g++.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/username/Projects/test/build/CMakeFiles/CMakeTmp
Run Build Command(s):make -f Makefile cmTC_2f478/fast && make -f CMakeFiles\cmTC_2f478.dir\build.make CMakeFiles/cmTC_2f478.dir/build
'mTC_2f478.dir' is not recognized as an internal or external command,
operable program or batch file.
make: *** [Makefile:126: cmTC_2f478/fast] Error 1
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:3 (project)
-- Configuring incomplete, errors occurred!
See also "C:/Users/username/Projects/test/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/username/Projects/test/build/CMakeFiles/CMakeError.log".
编译器的安装路径位于 PATH
中。
> where.exe g++
C:\cygwin64\bin\g++.exe
我还尝试使用 g++.exe main -o main.cpp
构建 hello world
并且工作正常。
I'm trying to setup cmake
on Windows 11 x64.
I'm using MinGW Makefiles
and make.exe
for the building. I installed the compiler and make
using Cygwin
. The compiler is a native compiler.
My CMakeLists.txt contains the following:
cmake_minimum_required(VERSION 3.20)
project(hello CXX)
add_executable(hello main.cpp)
Inside the build
directory I run the following command:cmake -G "MinGW Makefiles" -DCMAKE_MAKE_PROGRAM=make ..
The output I get:
-- The CXX compiler identification is GNU 11.2.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: C:/cygwin64/bin/g++.exe
-- Check for working CXX compiler: C:/cygwin64/bin/g++.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeTestCXXCompiler.cmake:62 (message):
The C++ compiler
"C:/cygwin64/bin/g++.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/username/Projects/test/build/CMakeFiles/CMakeTmp
Run Build Command(s):make -f Makefile cmTC_2f478/fast && make -f CMakeFiles\cmTC_2f478.dir\build.make CMakeFiles/cmTC_2f478.dir/build
'mTC_2f478.dir' is not recognized as an internal or external command,
operable program or batch file.
make: *** [Makefile:126: cmTC_2f478/fast] Error 1
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:3 (project)
-- Configuring incomplete, errors occurred!
See also "C:/Users/username/Projects/test/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/username/Projects/test/build/CMakeFiles/CMakeError.log".
The path the compiler is installed is in PATH
.
> where.exe g++
C:\cygwin64\bin\g++.exe
Also I tried building a hello world
using g++.exe main -o main.cpp
and worked fine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论