I am working on an embedded Linux system (5.10.24), and there is a LCD display in it.
Now I am trying to run a SDL2 example in it (from serial console), but I failed to do that.
The example codes are as follows,

#include "SDL2/SDL.h"

int main(int argc, char* argv[])
        SDL_Window* window;
        SDL_Renderer* renderer;

        if (SDL_Init(SDL_INIT_VIDEO) < 0) {
                printf("error initializing SDL: %s\n", SDL_GetError());
                return 1;

        window = SDL_CreateWindow("SDL_RenderClear",
                                    512, 512, 0);

        renderer = SDL_CreateRenderer(window, -1, 0);
        SDL_SetRenderDrawColor(renderer, 64, 255, 128, 255);


        return 0;

It is compiled as mips-linux-gnu-gcc -g2 sdl_ex1.c -I/sysroot/usr/include/ -Lsysroot/usr/lib/ -lSDL2 -lts -o sdl_ex1.

When I ran it from serial console, it failed with following error.

~ # ./sdl_ex1
error initializing SDL: No available video device
~ # echo $DISPLAY

~ #

But I can run it correctly in Xterm in Ubuntu-20.04 VM. Where a new window poped up and showed something in it. And the $DISPLAY is ':1' in Ubuntu-20.04.

In the embedded system, there are 2 framebuffer devices, /dev/fb0 and /dev/fb1. But there is NO libX11 or other X stuffs.

An GUI is running in the LCD display, so in this system, how can I run SDL application ?

1 Answer 1


With Keltar and David's comments from StackOverflow, I finally worked it out. I rebuilt target root filesystem with directfb and SDL2 with directfb. After that, I set export SDL_VIDEODRIVER=directfb in the shell in the target.

Then I can start SDL2 example, which can draw window and do redendering in the window.

This is what I expected.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .