Problem
I would like to have gtest installed in my Windows 11 machine and run the program using MinGW for Windows 11; i.e., the gcc compiler that comes with MinGW.
I have the environment variables properly set so that I can use the MinGW commands from Powershell and the cmake environment variables too.
What is happening.
I am trying to install gtest for Windows 11 through MinGW-w64, but when running the cmake
command it says:
-- Building for: Visual Studio 17 2022
I would like for it to build for MinGW-w64.
Potentially Useful Information.
The procedure I am using to install gtest is the following:
- I go to https://github.com/google/googletest and clone the folder into the MinGW folder.
- I go into the googletest folder and create a build folder.
- I navigate into the build folder such that my location is now:
c:\MinGW\googletest\build\
- From this location, using Powershell, I run:
cmake ..
This is the message that I get:
-- Building for: Visual Studio 17 2022
-- The C compiler identification is MSVC 19.33.31629.0
-- The CXX compiler identification is MSVC 19.33.31629.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Python: C:/Users/xyz/AppData/Local/Programs/Python/Python310/python.exe (found version "3.10.5") found components: Interpreter
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: C:/MinGW/googletest/build
that indicates that the compiler is for Visual Studio 17 2022. I would wish the compiler that is used to be:
g++.exe (MinGW.org GCC-6.3.0-1) 6.3.0
That is the compiler that is distributed with the version of MinGW that I have. Of course, in this case,pthreads
will be disabled and I would not be able to run it as:
g++ -std=c++17 -pthread ./<whatever>.cpp -lgtest -lgtest_main
that is the way I like to run it from my Linux machine...that unfortunately I cannot use...as often as I'd wish.
Final Remark(s)
If there is a way for gtest to be used using the MinGW compiler from Powershell, it would be much appreciated.