K
K
Kirill H2018-04-01 20:02:00
MinGW
Kirill H, 2018-04-01 20:02:00

Why doesn't CMake generate files under MinGW without the CMAKE_GNUtoMS flag?

Hello,
I tried to build an example program for MinGW using CMake.
At first there was a problem that CMake did not see the compiler, it was solved by adding the path "C:\MinGW\bin" to the PATH variable. The error is gone, however, one more remains:

Error Log ↓
PS C:\test> cmake -G "MinGW Makefiles"
-- The C compiler identification is GNU 6.3.0
CMake Error at C:/Program Files/CMake/share/cmake-3.11/Modules/CMakeDetermineCompilerId.cmake:495 (file):
  file STRINGS file "C:/test/CMakeFiles/3.11.0/CompilerIdCXX/a.exe" cannot be
  read.
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.11/Modules/CMakeDetermineCompilerId.cmake:37 (CMAKE_DETERMINE_COMPILER_ID_CHECK)
  C:/Program Files/CMake/share/cmake-3.11/Modules/CMakeDetermineCXXCompiler.cmake:107 (CMAKE_DETERMINE_COMPILER_ID)
  CMakeLists.txt:1 (project)


CMake Error at C:/Program Files/CMake/share/cmake-3.11/Modules/CMakeDetermineCompilerId.cmake:501 (list):
  list sub-command REMOVE_DUPLICATES requires list to be present.
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.11/Modules/CMakeDetermineCompilerId.cmake:37 (CMAKE_DETERMINE_COMPILER_ID_CHECK)
  C:/Program Files/CMake/share/cmake-3.11/Modules/CMakeDetermineCXXCompiler.cmake:107 (CMAKE_DETERMINE_COMPILER_ID)
  CMakeLists.txt:1 (project)


CMake Error at C:/Program Files/CMake/share/cmake-3.11/Modules/CMakeDetermineCompilerId.cmake:567 (file):
  file failed to open for reading (Invalid argument):

    C:/test/CMakeFiles/3.11.0/CompilerIdCXX/a.exe
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.11/Modules/CMakeDetermineCompilerId.cmake:37 (CMAKE_DETERMINE_COMPILER_ID_CHECK)
  C:/Program Files/CMake/share/cmake-3.11/Modules/CMakeDetermineCXXCompiler.cmake:107 (CMAKE_DETERMINE_COMPILER_ID)
  CMakeLists.txt:1 (project)


CMake Error at C:/Program Files/CMake/share/cmake-3.11/Modules/CMakeDetermineCompilerId.cmake:569 (string):
  string begin index: 1 is out of range 0 - 0
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.11/Modules/CMakeDetermineCompilerId.cmake:37 (CMAKE_DETERMINE_COMPILER_ID_CHECK)
  C:/Program Files/CMake/share/cmake-3.11/Modules/CMakeDetermineCXXCompiler.cmake:107 (CMAKE_DETERMINE_COMPILER_ID)
  CMakeLists.txt:1 (project)


CMake Error at C:/Program Files/CMake/share/cmake-3.11/Modules/CMakeDetermineCompilerId.cmake:577 (math):
  math cannot parse the expression: " * 16 + ": syntax error, unexpected
  exp_TIMES, expecting exp_PLUS or exp_MINUS or exp_OPENPARENT or exp_NUMBER
  (2)
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.11/Modules/CMakeDetermineCompilerId.cmake:37 (CMAKE_DETERMINE_COMPILER_ID_CHECK)
  C:/Program Files/CMake/share/cmake-3.11/Modules/CMakeDetermineCXXCompiler.cmake:107 (CMAKE_DETERMINE_COMPILER_ID)
  CMakeLists.txt:1 (project)


CMake Error at C:/Program Files/CMake/share/cmake-3.11/Modules/CMakeDetermineCompilerId.cmake:579 (file):
  file failed to open for reading (Invalid argument):

    C:/test/CMakeFiles/3.11.0/CompilerIdCXX/a.exe
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.11/Modules/CMakeDetermineCompilerId.cmake:37 (CMAKE_DETERMINE_COMPILER_ID_CHECK)
  C:/Program Files/CMake/share/cmake-3.11/Modules/CMakeDetermineCXXCompiler.cmake:107 (CMAKE_DETERMINE_COMPILER_ID)
  CMakeLists.txt:1 (project)


-- The CXX compiler identification is GNU 6.3.0
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring incomplete, errors occurred!
See also "C:/test/CMakeFiles/CMakeOutput.log".
See also "C:/test/CMakeFiles/CMakeError.log".

The issue is solved by simply adding the CMAKE_GNUtoMS flag at the start of CMake generation.
But to be honest, it's not clear:
  1. Why is this flag needed, or rather why is it impossible without it? The documentation does not give an exhaustive answer (yes, yes, it converts .dll.a to .lib, and, as I understand it, with the help of a studio compiler, judging by this article . I would like without this, please explain if I'm wrong and something I confuse).
  2. I think this is not the correct way to fix the problem, who knows the reason for its occurrence and how to solve it? By the way, I also added the "C:\MinGW\include" paths to PATH.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question