C++ cmake can';t编译单个测试程序mingww64 msys2:ld退出代码5
这是我第一次使用cmake,我正在尝试为mingw makefiles构建程序,但是,构建失败,cmake抱怨他无法构建简单的程序:C++ cmake can';t编译单个测试程序mingww64 msys2:ld退出代码5,c++,cmake,C++,Cmake,这是我第一次使用cmake,我正在尝试为mingw makefiles构建程序,但是,构建失败,cmake抱怨他无法构建简单的程序: CMake Warning: No source or binary directory provided. Both will be assumed to be the same as the current working directory, but note that this warning will become a fatal erro
CMake Warning:
No source or binary directory provided. Both will be assumed to be the
same as the current working directory, but note that this warning will
become a fatal error in future CMake releases.
-- The C compiler identification is GNU 10.2.0
-- The CXX compiler identification is GNU 10.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: D:/msys2/mingw64/bin/gcc.exe
-- Check for working C compiler: D:/msys2/mingw64/bin/gcc.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.19/Modules/CMakeTestCCompiler.cmake:66 (message):
The C compiler
"D:/msys2/mingw64/bin/gcc.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: D:/code/cpp/discord/CMakeFiles/CMakeTmp
Run Build Command(s):D:/msys2/mingw64/bin/mingw32-make.exe cmTC_e2ef0/fast && D:/msys2/mingw64/bin/mingw32-make.exe -f CMakeFiles\cmTC_e2ef0.dir\build.make CMakeFiles/cmTC_e2ef0.dir/build
mingw32-make[1]: Entering directory 'D:/code/cpp/discord/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_e2ef0.dir/testCCompiler.c.obj
D:\msys2\mingw64\bin\gcc.exe -o CMakeFiles\cmTC_e2ef0.dir\testCCompiler.c.obj -c D:\code\cpp\discord\CMakeFiles\CMakeTmp\testCCompiler.c
Linking C executable cmTC_e2ef0.exe
"C:\Program Files\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_e2ef0.dir\link.txt --verbose=1
"C:\Program Files\CMake\bin\cmake.exe" -E rm -f CMakeFiles\cmTC_e2ef0.dir/objects.a
D:\msys2\mingw64\bin\ar.exe cr CMakeFiles\cmTC_e2ef0.dir/objects.a @CMakeFiles\cmTC_e2ef0.dir\objects1.rsp
D:\msys2\mingw64\bin\gcc.exe -Wl,--whole-archive CMakeFiles\cmTC_e2ef0.dir/objects.a -Wl,--no-whole-archive -o cmTC_e2ef0.exe -Wl,--out-implib,libcmTC_e2ef0.dll.a -Wl,--major-image-version,0,--minor-image-version,0 @CMakeFiles\cmTC_e2ef0.dir\linklibs.rsp
collect2.exe: error: ld returned 5 exit status
mingw32-make[1]: *** [CMakeFiles\cmTC_e2ef0.dir\build.make:107: cmTC_e2ef0.exe] Error 1
mingw32-make[1]: *** Deleting file 'cmTC_e2ef0.exe'
mingw32-make[1]: Leaving directory 'D:/code/cpp/discord/CMakeFiles/CMakeTmp'
mingw32-make: *** [Makefile:139: cmTC_e2ef0/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "D:/code/cpp/discord/CMakeFiles/CMakeOutput.log".
See also "D:/code/cpp/discord/CMakeFiles/CMakeError.log".
我正在使用MSYS2项目中的mingww64,如果这有帮助的话…您需要从MSYS2项目中安装cmake这是否回答了您的问题@Kiskae它指出了如果您手动键入命令,如何“可能”修复问题,但我使用的是cmake…编辑:似乎您需要从msys2而不是从官方网站安装cmake,我是通过msys2安装的,它成功了,解决了此问题