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

**URL:** <https://discourse.glfw.org/t/which-mingw-version-to-use-source-compilation-and-using-library/1789>\
**Category:** support\
**Created:** [March 11, 2021, 9:21am UTC](https://discourse.glfw.org/t/which-mingw-version-to-use-source-compilation-and-using-library/1789 "2021-03-11T09:21:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nezvers](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/nezvers/32/477_2.png) [@nezvers](https://discourse.glfw.org/u/nezvers)\
**Post date:** [March 11, 2021, 9:21am UTC](https://discourse.glfw.org/t/which-mingw-version-to-use-source-compilation-and-using-library/1789/1 "2021-03-11T09:21:26Z")

</div>

I’ve tried several versions and can’t get an example code compiling - [stackoverflow post](https://stackoverflow.com/questions/66570329/glfw-with-gcc-mingw-flags-for-static-doesnt-work-as-documented). 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:

```auto
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?

---

<div class="post-metadata">

**Author:** ![nezvers](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/nezvers/32/477_2.png) [@nezvers](https://discourse.glfw.org/u/nezvers)\
**Post date:** [March 11, 2021, 9:46am UTC](https://discourse.glfw.org/t/which-mingw-version-to-use-source-compilation-and-using-library/1789/2 "2021-03-11T09:46:14Z")

</div>

Same cmake error with GNU mingw

```auto
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)

```

---

<div class="post-metadata">

**Author:** ![elmindreda](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/elmindreda/32/26_2.png) [@elmindreda](https://discourse.glfw.org/u/elmindreda)\
**Post date:** [March 23, 2021, 8:43pm UTC](https://discourse.glfw.org/t/which-mingw-version-to-use-source-compilation-and-using-library/1789/3 "2021-03-23T20:43:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nezvers](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/nezvers/32/477_2.png) [@nezvers](https://discourse.glfw.org/u/nezvers)\
**Post date:** [March 25, 2021, 11:31am UTC](https://discourse.glfw.org/t/which-mingw-version-to-use-source-compilation-and-using-library/1789/4 "2021-03-25T11:31:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [March 25, 2021, 12:48pm UTC](https://discourse.glfw.org/t/which-mingw-version-to-use-source-compilation-and-using-library/1789/5 "2021-03-25T12:48:30Z")

</div>

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