C++ was the very first language that got me into programming, when I was 16. At the time, I only had Visual Studio C++ installed, and had no idea how programming worked. But somehow, from there, programming became a huge part of my life, alongside drawing. Sometimes I even forget I’m an artist, because I code so much.

In my previous post I talked about how I couldn’t compile my SDL and Heaps.io code. I said I gave up. But I was bothered; I should’ve been able to do something as simple as compiling a Hello World program. I refused to install more and more tools to troubleshoot my setup, because I wanted to get things done quickly and jump right into coding games.

So I bit the bullet and challenged myself to go back to basics… To start from scratch with C++.

I installed all the requisites I thought I needed; Visual Studio Community Edition, Microsoft Visual C++, various versions of GCC (MinGW, CygWin, CodeBlocks), went through C++ tutorials, read up on Makefile and GCC documentation…

And I did it!

I managed to compile LazyFoo’s SDL HelloWorld program with only MinGW. I found out that I didn’t need all those extra programs to get my code to compile. I just had to get the right SDKs, and link them in my gcc build command.

And on that note, once I figured out the concept of linking “include” and “lib” folders, I managed to use Visual Studio Code with SDL, without needing the bloat of Visual Studio Community Edition, which installed a lot of additional tools that totalled up to 7gb. In comparison, the SDKs I needed were only about 400mb. Thanks to this lesson, I could uninstall everything else with a peace of mind.

I then took another step further, and compiled the same SDL program into JS using Emscripten. And by doing so, I finally understood why Web Assembly file size from Ebiten was huge; It’s because WASM does not assume dependencies – everything is sandboxed within its own data files. I’m guessing Ebiten has other dependencies that get bundled up into its 8mb filesize, but I won’t bother investigating that. For a basic SDL project, the compiled JS project is about 800kb. When gzipped, it goes down to 200kb. I was very pleased.

I wanted to make a simple game in my free time, but I ended up going down the rabbit hole of environment setup again. I’m not in a hurry right now so I’ll cut myself some slack and just keep learning stuff.

It feels great to learn and figure things out; Just like how I felt when I compiled my first Hello World console program when I was 16.