How to move a SDL project from Windows to Linux

It’s not actually that hard to do, there’s just a few things that are different between C and Linux, specifically between MSVC and GCC /Clang.. I did this when I wrote the Asteroids game in the book.
Originally I developed it on Windows then moved it to Linux (Ubuntu) and then I added the bits to have it work on a Raspberry Pi. It worked on the Pi more or less as is on Ubuntu but I added support for game pad, detecting that it was on a Pi and displaying the temperature.
Here’s what I’ve found is different between MSVC and GCC/Clang.
- The safe string functions. MSVC has the _s functions so instead of strcpy, there’s strcpy_s on MSVC. This doesn’t exists in GCC/Clang but there are similar functions with an n in the middle e.g. strncpy. In future I’ll create a macro for each function that uses the appropriate type so the compiler will pick the correct type. However it seems even strncpy may not be all that safe. If there is no \0 in the n characters then the copied string won’t have a terminating \0 and thus could still blow up. This article says that in order of safety it goes like this with strcpy least safe and strlcpy the most.
strcpy < strncpy < snprintf < strlcpy
so maybe I should be using strlcpy instead.
- The include path for SDL in GCC/Clang is “SDL\SDL.h” not “SDL.h” as it is in MSVC. Again this could be fixed with a macro prefix for the SDL path so all #include works correctly on either system.
3. I found that the file type was wrong. This wasn’t just a matter of CR/LF versus LF which you get between Windows and Linux (CR = Carriage return, LF = Line feed). Somehow the Windows file had a different UTF encoding type to what GCC/Clang expected and the compiler did not like it. However Visual Studio Code shows you what encoding it is (on the bottom of the edit window) and lets you change it, so no harm done. You may need to do this once on each file you’ve moved from Windows to Linux.
4. I found that the time header file in Linux needed a bit of work to make it compile. The standard for this dictates that differences aren’t done to the header file but by adding in additional headers.
So I’ll look into strlcpy.

When I created the Asteroids game, I deliberately didn’t use SDL_TTF instead I took a Monospaced font and saved it out as a PNG file which was loaded into a SDL Texture. I then created my own character printing routines by figuring out which character I wanted and then blitting it. The image shows the font I used zoomed in.


Sometimes I walk up around 3:00 AM and my mind is abuzz with things like this. Last night was one such night. The first thought was I should stop calling it a Roguelike. There’s a certain set of conventions with those and I don’t want to be limited by that.
One of the big problems with Hyper-V and Ubuntu in particular is the clipboard or lack of it. I had 18.04 LTS installed with an X Org RDP login. This worked perfectly and I could have a full screen in my Monitor and could copy/paste. Don’t underestimate copy/paste.
Seems to be with Visual Studio Code. I said yesterday that it had got into a funny state. Well I created a new VM and installed the Raspberry Pi OS that runs in a VM and after it updated tried installing VS Code on it.
It happened to me today, not once but twice. First the Hyper-V version of Raspberry PI OS I have installed (handy for screenshots) didn’t update properly. Apt got itself in a right state and attempts to fix broken packages on APT just made things worse. In the end, I fetched another copy 