CMake:C ++编译器“ C:/ MinGW / bin / g ++。exe”无法编译简单的测试程序

时间:2020-03-07 06:21:58

标签: c++ windows cmake mingw

我在编译一个非常简单的CMakeLists.txt

时就明白了
C:\Users\LZ\sw\test\integrations\cmake\tess>cmake -G "MinGW Makefiles" .
-- The CXX compiler identification is unknown
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.17/Modules/CMakeTestCXXCompiler.cmake:53 (message):
  The C++ compiler

    "C:/MinGW/bin/g++.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: C:/Users/LZ/sw/test/integrations/cmake/tess/CMakeFiles/CMakeTmp

    Run Build Command(s):C:/MinGW/bin/mingw32-make.exe cmTC_37ce9/fast && C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\cmTC_37ce9.dir\build.make CMakeFiles/cmTC_37ce9.dir/build
    mingw32-make.exe[1]: Entering directory 'C:/Users/LZ/sw/test/integrations/cmake/tess/CMakeFiles/CMakeTmp'
    Building CXX object CMakeFiles/cmTC_37ce9.dir/testCXXCompiler.cxx.obj
    C:\MinGW\bin\g++.exe     -o CMakeFiles\cmTC_37ce9.dir\testCXXCompiler.cxx.obj -c C:\Users\LZ\sw\test\integrations\cmake\tess\CMakeFiles\CMakeTmp\testCXXCompiler.cxx
    CMakeFiles\cmTC_37ce9.dir\build.make:81: recipe for target 'CMakeFiles/cmTC_37ce9.dir/testCXXCompiler.cxx.obj' failed
    mingw32-make.exe[1]: *** [CMakeFiles/cmTC_37ce9.dir/testCXXCompiler.cxx.obj] Error 1
    mingw32-make.exe[1]: Leaving directory 'C:/Users/LZ/sw/test/integrations/cmake/tess/CMakeFiles/CMakeTmp'
    Makefile:137: recipe for target 'cmTC_37ce9/fast' failed
    mingw32-make.exe: *** [cmTC_37ce9/fast] Error 2





  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/LZ/sw/test/integrations/cmake/tess/CMakeFiles/CMakeOutput.log".
See also "C:/Users/LZ/sw/test/integrations/cmake/tess/CMakeFiles/CMakeError.log".

这里是C:/Users/LZ/sw/test/integrations/cmake/tess/CMakeFiles/CMakeError.log

Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: C:/MinGW/bin/g++.exe
Build flags:
Id flags:  

The output was:
1


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: C:/MinGW/bin/g++.exe
Build flags:
Id flags: -c

The output was:
1


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: C:/MinGW/bin/g++.exe
Build flags:
Id flags: --c++

The output was:
1
g++.exe: error: unrecognized command line option '--c++'


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: C:/MinGW/bin/g++.exe
Build flags:
Id flags: --ec++

The output was:
1
g++.exe: error: unrecognized command line option '--ec++'; did you mean '-Weffc++'?


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: C:/MinGW/bin/g++.exe
Build flags:
Id flags: --target=arm-arm-none-eabi;-mcpu=cortex-m3

The output was:
1
g++.exe: warning: '-mcpu=' is deprecated; use '-mtune=' or '-march=' instead
g++.exe: error: unrecognized command line option '--target=arm-arm-none-eabi'


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: C:/MinGW/bin/g++.exe
Build flags:
Id flags:  

The output was:
1


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: C:/MinGW/bin/g++.exe
Build flags:
Id flags: -c

The output was:
1


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: C:/MinGW/bin/g++.exe
Build flags:
Id flags: --c++

The output was:
1
g++.exe: error: unrecognized command line option '--c++'


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: C:/MinGW/bin/g++.exe
Build flags:
Id flags: --ec++

The output was:
1
g++.exe: error: unrecognized command line option '--ec++'; did you mean '-Weffc++'?


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: C:/MinGW/bin/g++.exe
Build flags:
Id flags: --target=arm-arm-none-eabi;-mcpu=cortex-m3

The output was:
1
g++.exe: warning: '-mcpu=' is deprecated; use '-mtune=' or '-march=' instead
g++.exe: error: unrecognized command line option '--target=arm-arm-none-eabi'


Checking whether the CXX compiler is IAR using "" did not match "IAR .+ Compiler":
g++.exe: fatal error: no input files
compilation terminated.
Checking whether the CXX compiler is IAR using "" did not match "IAR .+ Compiler":
g++.exe: fatal error: no input files
compilation terminated.
Determining if the CXX compiler works failed with the following output:
Change Dir: C:/Users/LZ/sw/test/integrations/cmake/tess/CMakeFiles/CMakeTmp

Run Build Command(s):C:/MinGW/bin/mingw32-make.exe cmTC_b7c4e/fast && C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\cmTC_b7c4e.dir\build.make CMakeFiles/cmTC_b7c4e.dir/build

mingw32-make.exe[1]: Entering directory 'C:/Users/LZ/sw/test/integrations/cmake/tess/CMakeFiles/CMakeTmp'

Building CXX object CMakeFiles/cmTC_b7c4e.dir/testCXXCompiler.cxx.obj

C:\MinGW\bin\g++.exe     -o CMakeFiles\cmTC_b7c4e.dir\testCXXCompiler.cxx.obj -c C:\Users\LZ\sw\test\integrations\cmake\tess\CMakeFiles\CMakeTmp\testCXXCompiler.cxx

CMakeFiles\cmTC_b7c4e.dir\build.make:81: recipe for target 'CMakeFiles/cmTC_b7c4e.dir/testCXXCompiler.cxx.obj' failed

mingw32-make.exe[1]: *** [CMakeFiles/cmTC_b7c4e.dir/testCXXCompiler.cxx.obj] Error 1

mingw32-make.exe[1]: Leaving directory 'C:/Users/LZ/sw/test/integrations/cmake/tess/CMakeFiles/CMakeTmp'

Makefile:137: recipe for target 'cmTC_b7c4e/fast' failed

mingw32-make.exe: *** [cmTC_b7c4e/fast] Error 2

即使我未在CMakeLists.txt中指定交叉编译,MinGW似乎也认为我正在交叉编译。或者它只是尝试一些交叉编译的东西,但是错误的原因就在于另一件事。

我正在PowerShell上运行它。我也尝试了cmd.exe。它可以在MSYS2的MinGW64 shell上运行,但这与C:/MinGW/bin/g++.exe没有关系,我不能使用其他shell,因为它抱怨sw.exe在路径中,我无法取出它因为我必须运行sw setup

我该如何解决这个问题?

0 个答案:

没有答案
相关问题