Which MinGW version to use (source compilation and using library)?

I’ve tried several versions and can’t get an example code compiling - stackoverflow post. long list undefined reference to __mingw_free’` either GNU or LLVM MinGW

I tried to compile the source with llvm mingw-w64 but Cmake gave error:

D:\Dev\C\glfw-3.3.3>cmake .
-- The C compiler identification is Clang 11.0.0
-- Detecting C compiler ABI info
CMake Error: Generator: execution of make failed. Make command was: nmake -f Makefile /nologo cmTC_edc31\fast &&
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: D:/MinGW/llvm-mingw/bin/gcc.exe
CMake Error: Generator: execution of make failed. Make command was: nmake -f Makefile /nologo cmTC_d98c9\fast &&
-- Check for working C compiler: D:/MinGW/llvm-mingw/bin/gcc.exe - broken
CMake Error at D:/program Files/CMake/share/cmake-3.20/Modules/CMakeTestCCompiler.cmake:66 (message):
  The C compiler
    "D:/MinGW/llvm-mingw/bin/gcc.exe"
  is not able to compile a simple test program.
  It fails with the following output:
    Change Dir: D:/Dev/C/glfw-3.3.3/CMakeFiles/CMakeTmp

    Run Build Command(s):nmake -f Makefile /nologo cmTC_d98c9\fast && The system cannot find the file specified
    Generator: execution of make failed. Make command was: nmake -f Makefile /nologo cmTC_d98c9\fast &&

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

Please, can you give me a link to an exact version that works?

Same cmake error with GNU mingw

D:\Dev\C\glfw-3.3.3>cmake .
-- Building for: NMake Makefiles
-- The C compiler identification is GNU 8.1.0
-- Detecting C compiler ABI info
CMake Error: Generator: execution of make failed. Make command was: nmake -f Makefile /nologo cmTC_5d50a\fast &&
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: D:/MinGW/mingw-gnu/bin/gcc.exe
CMake Error: Generator: execution of make failed. Make command was: nmake -f Makefile /nologo cmTC_2c414\fast &&
-- Check for working C compiler: D:/MinGW/mingw-gnu/bin/gcc.exe - broken
CMake Error at D:/program Files/CMake/share/cmake-3.20/Modules/CMakeTestCCompiler.cmake:66 (message):
  The C compiler
    "D:/MinGW/mingw-gnu/bin/gcc.exe"

  is not able to compile a simple test program.
  It fails with the following output:
    Change Dir: D:/Dev/C/glfw-3.3.3/CMakeFiles/CMakeTmp
    Run Build Command(s):nmake -f Makefile /nologo cmTC_2c414\fast && The system cannot find the file specified
    Generator: execution of make failed. Make command was: nmake -f Makefile /nologo cmTC_2c414\fast &&

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

The issue may be that you’re requesting NMake Makefiles instead of MinGW Makefiles.

How to change that? I just did as the building guide said.

I’m not sure how your setup has become configured for nmake but using gcc, however you can get cmake to use the MinGW Makefile generator by using the -G "MinGW Makefiles" option:

cmake -G "MinGW Makefiles" .