Компиляция теста Google с Mingw-w64 - PullRequest
1 голос
/ 08 ноября 2019

Я пытаюсь скомпилировать Google Test с Mingw-w64 на компьютере с Windows 10, но всегда получаю сообщение об ошибке:

C:\git\tdd\googletest>cmake CMakeLists.txt -G "MinGW Makefiles"
CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!

Вот что я делаю:

  1. Откройте терминал Windows CMD и измените папку t, в которую я скачал google test
  2. Добавьте CMake, make и g ++ к пути set PATH="C:\Program Files\CMake\bin";"C:\msys\bin";"C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin";%PATH%
  3. Запустите CMake с cmake CMakeLists.txt -G "MinGW Makefiles"

Это версии инструментов:

GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i686-pc-msys
  • cmake версия 3.15.3
  • g ++ (i686-posix-dwarf-rev0, встроенныйПроект MinGW-W64) 8.1.0

Make поставляется из пакета MSYS от Mingw-64w . Я клонировал Google Test из здесь

Любая помощь очень ценится!

EDIT 1

Ни одно из решений в CMake / MinGW неизвестноcompilers, gcc.exe не работает работа.

EDIT 2

Я также пытался использовать переменные окружения, чтобы указать CMake, какие инструменты использовать.

  1. Добавилпапки инструментов в ПУТИ:

set PATH="C:\Program Files\CMake\bin";"C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin";%PATH%

Вызов CMake с

cmake -DCMAKE_C_COMPILER="C:/Program Files (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin/gcc" -DCMAKE_CXX_COMPILER="C:/Program Files (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin/g++" -DCMAKE_MAKE_PROGRAM="C:/Program Files (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin/mingw32-make.exe" CMakeLists.txt -G "MinGW Makefiles"

Я получаю эту ошибку:

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:10 (project):
  The CMAKE_C_COMPILER:

    C:/Program Files (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin/gcc

  is not a full path to an existing compiler tool.

  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.


CMake Error at CMakeLists.txt:10 (project):
  The CMAKE_CXX_COMPILER:

    C:/Program Files (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin/g++

  is not a full path to an existing compiler tool.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.


-- Configuring incomplete, errors occurred!
See also "C:/git/tdd/googletest/CMakeFiles/CMakeOutput.log".
See also "C:/git/tdd/googletest/CMakeFiles/CMakeError.log".

Поскольку g ++ и gcc находятся в PATH, я также пыталсявызвать CMake так:

cmake -DCMAKE_C_COMPILER="gcc" -DCMAKE_CXX_COMPILER="g++" -DCMAKE_MAKE_PROGRAM="mingw32-make.exe" CMakeLists.txt -G "MinGW Makefiles"

, что выдает ту же ошибку, что и предыдущая попытка:

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:10 (project):
  The CMAKE_C_COMPILER:

    gcc

  is not a full path and was not found in the PATH.

  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.


CMake Error at CMakeLists.txt:10 (project):
  The CMAKE_CXX_COMPILER:

    g++

  is not a full path and was not found in the PATH.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.


-- Configuring incomplete, errors occurred!
See also "C:/git/tdd/googletest/CMakeFiles/CMakeOutput.log".
See also "C:/git/tdd/googletest/CMakeFiles/CMakeError.log".

Однако я CAN Позвоните g++:

C:\git\tdd\googletest>g++
g++: fatal error: no input files
compilation terminated.

Еще раз спасибо!

Ответы [ 2 ]

0 голосов
/ 11 ноября 2019

Исходные проблемы связаны с выбором make.exe для MSYS2 вместе с компилятором MinGW-w64, который не поддерживается этой версией make.exe . Правильная программа для использования с MinGW-w64: mingw32-make.exe , которая является частью дистрибутива MinGW-w64. Я не могу полностью следовать вашим последующим изменениям, но, например, это прекрасно работает в cmd.exe :

set "PATH=C:\Program Files\CMake\bin;%PATH%"
set "PATH=C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;%PATH%"

cmake ^
    -G "MinGW Makefiles" ^
    -D CMAKE_C_COMPILER=gcc.exe ^
    -D CMAKE_CXX_COMPILER=g++.exe ^
    -D CMAKE_MAKE_PROGRAM=mingw32-make.exe ^
    .

mingw32-make.exe

Здесь я использовал:

0 голосов
/ 08 ноября 2019

ОК, мне удалось скомпилировать его, используя консоль CMDER Bash. Предполагая, что у вас установлен Mingw-w64 в C:\mingw-w64\ ( без пробелов в пути ), эти шаги приведут вас к работающей библиотеке тестов Google под Mingw-w64

  1. УстановитеПУТЬ к:

PATH=/c/Program\ Files/CMake/bin:/c/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin:$PATH

Вызов CMake с

cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_MAKE_PROGRAM=mingw32-make.exe CMakeLists.txt -G 'MSYS Makefiles'

Сборка с

mingw32-make.exe -j8

Я пойду здесь на конечность и скажу, что это, вероятно, должно работать с оболочкой Git Bash. У меня до сих пор нет решения для его сборки на обычном терминале Windows CMD.

...