CMake和MinGW-”等;C编译器无法编译简单的测试程序;

CMake和MinGW-”等;C编译器无法编译简单的测试程序;,cmake,mingw,Cmake,Mingw,我正在使用CMake和MinGW-w64位来构建。我在我的另一台电脑上使用了完全相同的设置和同一个编译器,它已经工作了。不知道怎么了 我的路径中有MinGW-w64垃圾箱。当我运行cmake并且没有指定编译器路径时,它会成功地生成MinGW makefile。但是,当我指定编译器时(我知道它可以工作,是从winlibs.com获得的),它会生成以下日志。我正在运行Windows 10 Detecting C compiler ABI info failed to compile with the

我正在使用CMake和MinGW-w64位来构建。我在我的另一台电脑上使用了完全相同的设置和同一个编译器,它已经工作了。不知道怎么了

我的路径中有MinGW-w64垃圾箱。当我运行cmake并且没有指定编译器路径时,它会成功地生成MinGW makefile。但是,当我指定编译器时(我知道它可以工作,是从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 CMakeFiles\cmTC_a01cd.dir\build.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:\MinGW\MinGW-10.1.0-64-bit\bin\x86_64-w64-mingw32-gcc.exe   -v -o CMakeFiles\cmTC_a01cd.dir\CMakeCCompilerABI.c.obj -c "C:\Program Files\CMake\share\cmake-3.18\Modules\CMakeCCompilerABI.c"

Using built-in specs.

COLLECT_GCC=C:\MinGW\MinGW-10.1.0-64-bit\bin\x86_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' 'CMakeFiles\cmTC_a01cd.dir\CMakeCCompilerABI.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:\mingw\mingw-10.1.0-64-bit\bin\../lib/gcc/x86_64-w64-mingw32/10.1.0/ -D_REENTRANT C:\Program Files\CMake\share\cmake-3.18\Modules\CMakeCCompilerABI.c -quiet -dumpbase CMakeCCompilerABI.c -mtune=generic -march=x86-64 -auxbase-strip CMakeFiles\cmTC_a01cd.dir\CMakeCCompilerABI.c.obj -version -o C:\Users\gvcal\AppData\Local\Temp\ccHRxkpy.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:\mingw\mingw-10.1.0-64-bit\bin\../lib/gcc/x86_64-w64-mingw32/10.1.0/include

 c:\mingw\mingw-10.1.0-64-bit\bin\../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../include

 c:\mingw\mingw-10.1.0-64-bit\bin\../lib/gcc/x86_64-w64-mingw32/10.1.0/include-fixed

 c:\mingw\mingw-10.1.0-64-bit\bin\../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' 'CMakeFiles\cmTC_a01cd.dir\CMakeCCompilerABI.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 CMakeFiles\cmTC_a01cd.dir\CMakeCCompilerABI.c.obj C:\Users\gvcal\AppData\Local\Temp\ccHRxkpy.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' 'CMakeFiles\cmTC_a01cd.dir\CMakeCCompilerABI.c.obj' '-c' '-mtune=generic' '-march=x86-64'

Linking C executable cmTC_a01cd.exe

"C:\Program Files\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_a01cd.dir\link.txt --verbose=1

"C:\Program Files\CMake\bin\cmake.exe" -E rm -f CMakeFiles\cmTC_a01cd.dir/objects.a
CMAKE_AR-NOTFOUND cr CMakeFiles\cmTC_a01cd.dir/objects.a @CMakeFiles\cmTC_a01cd.dir\objects1.rsp
Error running link command: The system cannot find the file specified
mingw32-make[1]: *** [CMakeFiles\cmTC_a01cd.dir\build.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 CMakeFiles\cmTC_f77ee.dir\build.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:\MinGW\MinGW-10.1.0-64-bit\bin\x86_64-w64-mingw32-gcc.exe    -o CMakeFiles\cmTC_f77ee.dir\testCCompiler.c.obj -c C:\Libraries\Projects\CMakeTest\build\MinGW-10.1.0-64-bit\debug\CMakeFiles\CMakeTmp\testCCompiler.c

Linking C executable cmTC_f77ee.exe

"C:\Program Files\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_f77ee.dir\link.txt --verbose=1

"C:\Program Files\CMake\bin\cmake.exe" -E rm -f CMakeFiles\cmTC_f77ee.dir/objects.a
CMAKE_AR-NOTFOUND cr CMakeFiles\cmTC_f77ee.dir/objects.a @CMakeFiles\cmTC_f77ee.dir\objects1.rsp
Error running link command: The system cannot find the file specified
mingw32-make[1]: *** [CMakeFiles\cmTC_f77ee.dir\build.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
命令行:

"C:\Program Files\CMake\bin\cmake.EXE" -Hc:/Libraries/Projects/CMakeTest -Bc:/Libraries/Projects/CMakeTest/build -G "MinGW Makefiles"

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


无论如何,我切换到忍者构建系统(),现在一切正常。

CMake似乎找不到
ar.exe
。能否显示您的
路径
的外观(ECHO%PATH%的输出)以及您使用的完整CMake命令行是什么?@BrechtSanders根据请求添加的。同样值得注意的是,它现在发生了两次,当时CMake告诉我它“找不到MinGW Makefiles的生成器”,而我清楚地知道你的构建在我的路径中。从路径中删除它并再次添加后,它两次都会再次工作,但对我来说这似乎很奇怪。。。不确定它是否相关。我倾向于在路径中更早地放置MinGW位置。例如,假设在您的示例中,“C:\Program Files(x86)\QuickTime\QTSystem\”包含与MinGW中同名的DLL,但一个是32位的,另一个是64位的?这有可能破坏一切。为什么要使用
-H
而不是
-S
来指定源位置?这不是问题的一部分,但是你有没有考虑过使用忍者而不是制造?这要快得多。我会早点把MinGW放进去,看看会发生什么!这些不是我输入的命令——它们是由用于VS代码的CMake工具扩展生成的!;)@不幸的是,这并没有解决问题。
"C:\Program Files\CMake\bin\cmake.EXE" -Hc:/Libraries/Projects/CMakeTest -Bc:/Libraries/Projects/CMakeTest/build -G "MinGW Makefiles"