Search code examples
cembeddedsdlbare-metal

Can a C program that uses SDL2 run in a bare metal environment (no Operating system)?


So I'm trying to design a program that takes a JSON file, parses it, and then creates a display on a touchscreen. So far I've written a program that does pretty much just that using Visual Studio, cJSON, and SDL2. However, the program is meant to be run on a bare metal STM microcontroller evaluation board. Is anything in the SDL library that is dependent on Windows or will the program run the same in a bare metal environment?


Solution

  • SDL exists in many platforms (Windows, Linux, AmigaOS & Nintendo DS, BeOS, Android, and probably others)

    But it relies on the operating system / hardware features to create display & sounds, and get input.

    If your microcontroller has no OS, SDL cannot be ported to it easily. So either you find a specific version of SDL on your platform or you'll have to port it yourself, which doesn't seem to be a piece of cake. Besides you probably need 5% of SDL features so why bother?

    The other solution would be to write your app without SDL, using the bare metal video/input capabilities of your microcontroller. It doesn't need to be portable, and you'll save time trying to port an abstract layer for your system for a simple app.