使用cmake与mingw-w64错误编译测试程序

时间:2016-04-21 13:57:57

标签: gcc cmake mingw-w64

我试图用mingw-w64和cmake进行简单的编译。但出于某种原因,我无法做到。它无法验证gcc是否可以编译一个奇怪的C程序。有任何想法吗?

由于

Paulo

C:\work\opencv\myown\hello>cmake -DCMAKE_CXX_COMPILER=g++ -DCMAKE_CC_COMPILER=gcc
-- The C compiler identification is GNU 5.3.0
-- The CXX compiler identification is GNU 5.3.0
-- Check for working C compiler: C:/Program Files/mingw-w64/x86_64-5.3.0-win32-seh-rt_v4-rev0/mingw64/bin/gcc.exe
CMake Error: Generator: execution of make failed. Make command was: "nmake" "/NOLOGO" "cmTC_8ce25\fast"
-- Check for working C compiler: C:/Program Files/mingw-w64/x86_64-5.3.0-win32-seh-rt_v4-rev0/mingw64/bin/gcc.exe -- broken
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.5/Modules/CMakeTestCCompiler.cmake:61 (message):
  The C compiler "C:/Program
  Files/mingw-w64/x86_64-5.3.0-win32-seh-rt_v4-rev0/mingw64/bin/gcc.exe" is
  not able to compile a simple test program.

  It fails with the following output:

   Change Dir: C:/work/opencv/myown/hello/CMakeFiles/CMakeTmp



  Run Build Command:"nmake" "/NOLOGO" "cmTC_8ce25\fast"



  Generator: execution of make failed.  Make command was: "nmake" "/NOLOGO"
  "cmTC_8ce25\fast"





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:7 (project)


-- Configuring incomplete, errors occurred!
See also "C:/work/opencv/myown/hello/CMakeFiles/CMakeOutput.log".
See also "C:/work/opencv/myown/hello/CMakeFiles/CMakeError.log".

1 个答案:

答案 0 :(得分:3)

nmake中有PATH吗?

您可以使用CMAKE_MAKE_PROGRAM提供另一个make命令,例如:

cmake -DCMAKE_CXX_COMPILER=g++ -DCMAKE_CC_COMPILER=gcc -DCMAKE_MAKE_PROGRAM=mingw32-make