# Having problems with CMake building SDL2 for msys mingw64 and CodeBlocks

**URL:** https://discourse.cmake.org/t/having-problems-with-cmake-building-sdl2-for-msys-mingw64-and-codeblocks/5495
**Category:** Usage
**Created:** [April 19, 2022, 9:29pm UTC](https://discourse.cmake.org/t/having-problems-with-cmake-building-sdl2-for-msys-mingw64-and-codeblocks/5495 "2022-04-19T21:29:03Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![PaulUK](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/7c8e57/32.png) [@PaulUK](https://discourse.cmake.org/u/PaulUK)
#### Post date: [April 19, 2022, 9:29pm UTC](https://discourse.cmake.org/t/having-problems-with-cmake-building-sdl2-for-msys-mingw64-and-codeblocks/5495/1 "2022-04-19T21:29:03Z")

</div>

Hello, first post here.

I’m getting errors when trying to select configure for building SDL2 using CodeBlocks and the non bundled mingw compiler. I will list the versions then the errors below.

OS: Win 7  
CMake: 3.23.1  
CodeBlocks: 20.03

Please note that this is CodeBlocks without the bundled mingw compiler. I have the msys compiler with both 32 and 64 bit versions of mingw installed in c:/msys/mingw64 which is the one I want to use. It is tested and works fine with CodeBlocks when selected.

I have the SDL2 sourcecode for version 2.0.20. I was following the instructions here ( [Install SDL With Code Blocks - YouTube](https://www.youtube.com/watch?v=lJRgwbRVtP0) ) but the process does not work, probably because I am using an alternative compiler in a different place.

The errors I get are as follows:

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!

If I specify the Codeblocks generator as my msys/mingw64 compiler I get the following:

Compilers are recognised but get CMAKE\_MAKE\_PROGRAM-NOTFOUND

even if I point to it I get the error:

libgmp-10.dll is mising from my computer.

The C compiler identification is unknown  
The CXX compiler identification is unknown  
Detecting C compiler ABI info

Please can someone advise me how I can build SDL2 libraries with CodeBlocks and the non bundled mingw compiler? Thank you.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [April 19, 2022, 9:32pm UTC](https://discourse.cmake.org/t/having-problems-with-cmake-building-sdl2-for-msys-mingw64-and-codeblocks/5495/2 "2022-04-19T21:32:32Z")

</div>

Is the toolchain and `make` program available on `PATH` in the terminal you’re using? Either way, you’ll also need to run an MSys-aware CMake (which should be available via `pacman`). The Windows binaries are for Windows environments. MinGW/MSys and Cygwin are two separate environments and each have their own build (because of the way they work).

---

<div class="post-metadata">

### Author: ![PaulUK](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/7c8e57/32.png) [@PaulUK](https://discourse.cmake.org/u/PaulUK)
#### Post date: [April 20, 2022, 9:20am UTC](https://discourse.cmake.org/t/having-problems-with-cmake-building-sdl2-for-msys-mingw64-and-codeblocks/5495/3 "2022-04-20T09:20:09Z")

</div>

Hi Ben,  
I do not have the toolchain in the PATH environment variable because it may cause confusion to have more than one compiler toolchain installed. I suppose I could just add the 64 bit version to PATH since that is the one I intend to use.  
Please can you advise how to add this MSys-aware CMake? How do I find it or the name to find it via pacman? I have only used CMake a couple of times in the past to do nothing out of the ordinary so I’m still very new to it. Thank you.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [April 20, 2022, 10:20am UTC](https://discourse.cmake.org/t/having-problems-with-cmake-building-sdl2-for-msys-mingw64-and-codeblocks/5495/4 "2022-04-20T10:20:46Z")

</div>

I’m not that familiar with `pacman`. Something like `pacman -S cmake` may work according to [this SO answer](https://stackoverflow.com/questions/65146595/how-to-install-and-configure-cmake-in-msys2). You can also just set the compiler path using `CC` and `CXX` environment variables or pass it through `-DCMAKE_C_COMPILER=` and `-DCMAKE_CXX_COMPILER=` arguments.

---

<div class="post-metadata">

### Author: ![PaulUK](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/7c8e57/32.png) [@PaulUK](https://discourse.cmake.org/u/PaulUK)
#### Post date: [April 23, 2022, 7:59pm UTC](https://discourse.cmake.org/t/having-problems-with-cmake-building-sdl2-for-msys-mingw64-and-codeblocks/5495/5 "2022-04-23T19:59:45Z")

</div>

I finally managed to get CMake to build the SDL2 library. All I had to do was to put the mingw 64 bit compiler toolchain folder “bin” into the PATH environment variable. All worked well after that. Thank for the tip, Ben.
