Having problems with CMake building SDL2 for msys mingw64 and CodeBlocks

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

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

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.

I’m not that familiar with pacman. Something like pacman -S cmake may work according to this SO answer. 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.

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.