Looking again at compiling a Windows Raylib app

Its become clear to me that there is some considerable misunderstanding about using the Windows Subsystem for Linux (WSL)

WSL is soely used for the compiler tools, you need only the command line tools.

There are NO runtime dependencies on WSL – your application will work on systems that don’t have WSL installed.

While trying to help people on various forums, I often directed them to use the makefile I’d provided in the previous tutorial, big oops I hadn’t actually provided an example project! My bad, this is rectified below!

I’ll briefly outline the steps you need to do after installing WSL (there are loads of tutorials out there for installing WSL)

Once you have installed WSL (I’m assuming Ubuntu here) and the bash prompt is running, its a good idea to create a folder for your work

mkdir development
cd development

Next lets install some tools

sudo apt-get install make git wget mingw-w64-x86-64-dev gcc-mingw-w64-x86-64

If I’ve missed some package that needs installing please do let me know!

The next thing to do is grab raylib and build it

git clone https://github.com/raysan5/raylib --depth=1
cd raylib/src
make OS=Windows_NT CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-ar -j`nproc`
cd ../..

Its worth mentioning the backtic operator (`) used in the -j parameter, this basically runs the nproc tool and stuffs the results into the -j parameter, this queries the number of cores on your system and tells make to use that many threads.

Assuming thats all gone okay, we can grab some example code…

wget http://bedroomcoders.co.uk/wp-content/uploads/2020/04/shader-mask.tar.gz
tar zxvf shader-mask.tar.gz
cd shader-mask

…and finally we can actually compile the example application

make -f Makefile.win

Hopefully you now have a nice shiny 64-bit windows executable!

I do monitor the raylib reddit channel quite often so please do stop by there if you spot an issue and help me update this so I can make it a better guide.

Leave a Reply

Your email address will not be published. Required fields are marked *