How to build on Mingw-w64

1,526 views
Skip to first unread message

Leonardo Pereira Santos

unread,
Nov 8, 2019, 12:40:49 PM11/8/19
to Google C++ Testing Framework
Hello Everybody!

I'm trying to build Google test on a Windows 10 machine with Mingw-w64 and I can't get this to work. I managed to build Google test with Cygwin and run some simple tests, but I'd like to use Mingw-w64.

Here's the steps of what I'm doing:

  1. Cloned https://github.com/google/googletest.git
  2. Open Windows terminal (CMD)
  3. Calling Cmake with 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"

I get the error:

C:\git\tdd\googletest>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".


I also tried adding CMake's and Mingw-w64's folders to the PATH:

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%

And calling CMake without the tools' full path:

C:\git\tdd\googletest>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".

This is not correct, I *CAN* call g++:

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

Any help is appreciated.


Leonardo Pereira Santos

unread,
Nov 8, 2019, 2:20:19 PM11/8/19
to Google C++ Testing Framework
OK, I got it to work with the following by biting the bullet and moving C:\Program Files (x86)\mingw-w64 to C:\

 1. Set the PATH to:
    PATH=/c/Program\ Files/CMake/bin:/c/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin:$PATH
 2. Invoke CMake with
    cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_MAKE_PROGRAM=mingw32-make.exe CMakeLists.txt -G 'MSYS Makefiles'
 3. Build with
    mingw32-make.exe -j8

This works in a CMDER Bash shell. I'm guessing this should also work with a Git Bash shell.

Doing the equivalent in the default Windows shell (CMD) does not work:

1. set PATH="C:\Program Files\CMake\bin";"C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin";%PATH%
2. cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_MAKE_PROGRAM=mingw32-make.exe CMakeLists.txt -G "MSYS Makefiles"

I get the error

-- 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.


CMake Error: CMAKE_AR was not found, please set to archive program. CMAKE_AR-NOTFOUND

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


Which, again, is stupid because g++ can be called in that console.


--

---
You received this message because you are subscribed to the Google Groups "Google C++ Testing Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to googletestframe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/googletestframework/c809fb5e-61f7-4f31-8eaf-bd3c53bf3425%40googlegroups.com.


--
"Watchdogs are for wimps. Real designers use supernovas in a distant galaxy to reset their boards."
itzly

Reply all
Reply to author
Forward
0 new messages