CMake 和 MinGW - "The C Compiler is not able to compile a simple test program"



我正在使用CMake和MinGW-w64 64位来构建。我已经在我的另一台PC上使用相同的编译器使用了完全相同的设置,并且它已经工作了。不知道出了什么问题。

我的路径中有 MinGW-w64 垃圾箱。当我运行 cmake 并且不指定编译器路径时,它会成功生成 MinGW 生成文件。但是,当我指定编译器(我知道它确实有效,我从 winlibs.com 那里得到它(时,它会生成以下日志。我正在运行Windows 10。

Detecting C compiler ABI info failed to compile with the following output:
Change Dir: C:/Libraries/Projects/CMakeTest/build/MinGW-10.1.0-64-bit/debug/CMakeFiles/CMakeTmp
Run Build Command(s):C:/MinGW/MinGW-10.1.0-64-bit/bin/mingw32-make.exe cmTC_a01cd/fast && C:/MinGW/MinGW-10.1.0-64-bit/bin/mingw32-make.exe  -f CMakeFilescmTC_a01cd.dirbuild.make CMakeFiles/cmTC_a01cd.dir/build
mingw32-make[1]: Entering directory 'C:/Libraries/Projects/CMakeTest/build/MinGW-10.1.0-64-bit/debug/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_a01cd.dir/CMakeCCompilerABI.c.obj
C:MinGWMinGW-10.1.0-64-bitbinx86_64-w64-mingw32-gcc.exe   -v -o CMakeFilescmTC_a01cd.dirCMakeCCompilerABI.c.obj -c "C:Program FilesCMakesharecmake-3.18ModulesCMakeCCompilerABI.c"
Using built-in specs.
COLLECT_GCC=C:MinGWMinGW-10.1.0-64-bitbinx86_64-w64-mingw32-gcc.exe
Target: x86_64-w64-mingw32
Configured with: ../configure --prefix=/R/winlibs64_10.1.0/inst_gcc-10.1.0/share/gcc --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --with-pkgversion='MinGW-W64 x86_64-posix-seh, built by Brecht Sanders' --with-tune=generic --enable-checking=release --enable-threads=posix --disable-sjlj-exceptions --disable-libunwind-exceptions --enable-serial-configure --disable-bootstrap --enable-host-shared --enable-plugin --enable-default-ssp --disable-rpath --disable-libstdcxx-pch --enable-libstdcxx-time=yes --disable-libstdcxx-debug --disable-version-specific-runtime-libs --with-stabs --disable-symvers --enable-languages=c,c++,fortran,lto,objc,obj-c++,d --disable-gold --disable-nls --disable-stage1-checking --disable-win32-registry --disable-multilib --enable-ld --enable-libquadmath --enable-libada --enable-libssp --enable-libstdcxx --enable-lto --enable-fully-dynamic-string --enable-libgomp --enable-graphite --enable-mingw-wildcard --with-mpc=/d/winlibs64_10.1.0/custombuilt --with-mpfr=/d/winlibs64_10.1.0/custombuilt --with-gmp=/d/winlibs64_10.1.0/custombuilt --with-isl=/d/winlibs64_10.1.0/custombuilt --enable-install-libiberty --enable-__cxa_atexit --without-included-gettext --with-diagnostics-color=auto --with-libiconv --with-system-zlib --with-build-sysroot=/R/winlibs64_10.1.0/gcc-10.1.0/build_mingw/mingw-w64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.1.0 (MinGW-W64 x86_64-posix-seh, built by Brecht Sanders) 
COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFilescmTC_a01cd.dirCMakeCCompilerABI.c.obj' '-c' '-mtune=generic' '-march=x86-64'
c:/mingw/mingw-10.1.0-64-bit/bin/../libexec/gcc/x86_64-w64-mingw32/10.1.0/cc1.exe -quiet -v -iprefix c:mingwmingw-10.1.0-64-bitbin../lib/gcc/x86_64-w64-mingw32/10.1.0/ -D_REENTRANT C:Program FilesCMakesharecmake-3.18ModulesCMakeCCompilerABI.c -quiet -dumpbase CMakeCCompilerABI.c -mtune=generic -march=x86-64 -auxbase-strip CMakeFilescmTC_a01cd.dirCMakeCCompilerABI.c.obj -version -o C:UsersgvcalAppDataLocalTempccHRxkpy.s
GNU C17 (MinGW-W64 x86_64-posix-seh, built by Brecht Sanders) version 10.1.0 (x86_64-w64-mingw32)
compiled by GNU C version 10.1.0, GMP version 6.2.0, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.22.1-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "c:/mingw/mingw-10.1.0-64-bit/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/10.1.0/include"
ignoring nonexistent directory "R:/winlibs64_10.1.0/inst_gcc-10.1.0/share/gcc/include"
ignoring nonexistent directory "/R/winlibs64_10.1.0/inst_gcc-10.1.0/share/gcc/include"
ignoring duplicate directory "c:/mingw/mingw-10.1.0-64-bit/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/10.1.0/include-fixed"
ignoring duplicate directory "c:/mingw/mingw-10.1.0-64-bit/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/include"
ignoring nonexistent directory "/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
c:mingwmingw-10.1.0-64-bitbin../lib/gcc/x86_64-w64-mingw32/10.1.0/include
c:mingwmingw-10.1.0-64-bitbin../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../include
c:mingwmingw-10.1.0-64-bitbin../lib/gcc/x86_64-w64-mingw32/10.1.0/include-fixed
c:mingwmingw-10.1.0-64-bitbin../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/include
End of search list.
GNU C17 (MinGW-W64 x86_64-posix-seh, built by Brecht Sanders) version 10.1.0 (x86_64-w64-mingw32)
compiled by GNU C version 10.1.0, GMP version 6.2.0, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.22.1-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 21a8d9a0add79f637093bff9641d5f35
COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFilescmTC_a01cd.dirCMakeCCompilerABI.c.obj' '-c' '-mtune=generic' '-march=x86-64'
c:/mingw/mingw-10.1.0-64-bit/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/as.exe -v -o CMakeFilescmTC_a01cd.dirCMakeCCompilerABI.c.obj C:UsersgvcalAppDataLocalTempccHRxkpy.s
GNU assembler version 2.34 (x86_64-w64-mingw32) using BFD version (Binutils for MinGW-W64 x86_64, built by Brecht Sanders) 2.34
COMPILER_PATH=c:/mingw/mingw-10.1.0-64-bit/bin/../libexec/gcc/x86_64-w64-mingw32/10.1.0/;c:/mingw/mingw-10.1.0-64-bit/bin/../libexec/gcc/;c:/mingw/mingw-10.1.0-64-bit/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/
LIBRARY_PATH=c:/mingw/mingw-10.1.0-64-bit/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/;c:/mingw/mingw-10.1.0-64-bit/bin/../lib/gcc/;c:/mingw/mingw-10.1.0-64-bit/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/lib/../lib/;c:/mingw/mingw-10.1.0-64-bit/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../lib/;c:/mingw/mingw-10.1.0-64-bit/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/lib/;c:/mingw/mingw-10.1.0-64-bit/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../
COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFilescmTC_a01cd.dirCMakeCCompilerABI.c.obj' '-c' '-mtune=generic' '-march=x86-64'
Linking C executable cmTC_a01cd.exe
"C:Program FilesCMakebincmake.exe" -E cmake_link_script CMakeFilescmTC_a01cd.dirlink.txt --verbose=1
"C:Program FilesCMakebincmake.exe" -E rm -f CMakeFilescmTC_a01cd.dir/objects.a
CMAKE_AR-NOTFOUND cr CMakeFilescmTC_a01cd.dir/objects.a @CMakeFilescmTC_a01cd.dirobjects1.rsp
Error running link command: The system cannot find the file specified
mingw32-make[1]: *** [CMakeFilescmTC_a01cd.dirbuild.make:107: cmTC_a01cd.exe] Error 2
mingw32-make[1]: Leaving directory 'C:/Libraries/Projects/CMakeTest/build/MinGW-10.1.0-64-bit/debug/CMakeFiles/CMakeTmp'
mingw32-make: *** [makefile:140: cmTC_a01cd/fast] Error 2


Determining if the C compiler works failed with the following output:
Change Dir: C:/Libraries/Projects/CMakeTest/build/MinGW-10.1.0-64-bit/debug/CMakeFiles/CMakeTmp
Run Build Command(s):C:/MinGW/MinGW-10.1.0-64-bit/bin/mingw32-make.exe cmTC_f77ee/fast && C:/MinGW/MinGW-10.1.0-64-bit/bin/mingw32-make.exe  -f CMakeFilescmTC_f77ee.dirbuild.make CMakeFiles/cmTC_f77ee.dir/build
mingw32-make[1]: Entering directory 'C:/Libraries/Projects/CMakeTest/build/MinGW-10.1.0-64-bit/debug/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_f77ee.dir/testCCompiler.c.obj
C:MinGWMinGW-10.1.0-64-bitbinx86_64-w64-mingw32-gcc.exe    -o CMakeFilescmTC_f77ee.dirtestCCompiler.c.obj -c C:LibrariesProjectsCMakeTestbuildMinGW-10.1.0-64-bitdebugCMakeFilesCMakeTmptestCCompiler.c
Linking C executable cmTC_f77ee.exe
"C:Program FilesCMakebincmake.exe" -E cmake_link_script CMakeFilescmTC_f77ee.dirlink.txt --verbose=1
"C:Program FilesCMakebincmake.exe" -E rm -f CMakeFilescmTC_f77ee.dir/objects.a
CMAKE_AR-NOTFOUND cr CMakeFilescmTC_f77ee.dir/objects.a @CMakeFilescmTC_f77ee.dirobjects1.rsp
Error running link command: The system cannot find the file specified
mingw32-make[1]: *** [CMakeFilescmTC_f77ee.dirbuild.make:108: cmTC_f77ee.exe] Error 2
mingw32-make[1]: Leaving directory 'C:/Libraries/Projects/CMakeTest/build/MinGW-10.1.0-64-bit/debug/CMakeFiles/CMakeTmp'
mingw32-make: *** [makefile:140: cmTC_f77ee/fast] Error 2

我的 PATH 和完整的命令行使用:

路径:

C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:WindowsSystem32OpenSSH;C:Program Files (x86)QuickTimeQTSystem;C:Program FilesMATLABR2019bbin;C:Program FilesMicrosoft VS Codebin;C:Program FilesCMakebin;C:MinGWMinGW-10.1.0-64-bitbin;C:UsersgvcalAppDataLocalMicrosoftWindowsApps;

命令行:

"C:Program FilesCMakebincmake.EXE" -Hc:/Libraries/Projects/CMakeTest -Bc:/Libraries/Projects/CMakeTest/build -G "MinGW Makefiles"

我认为这可能是CMake和MinGW Makefiles的错误。仍然不完全确定它是什么。

无论如何,我切换到忍者构建系统(https://ninja-build.org/(,现在一切正常。

最新更新