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",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
512, 512, 0);
renderer = SDL_CreateRenderer(window, -1, 0);
SDL_SetRenderDrawColor(renderer, 64, 255, 128, 255);
SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);
SDL_Delay(5000);
SDL_Quit();
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
~ #
The system is running in ARMv7 (quad core) and the GUI is a QT UI, Linux kernel is 5.10.24. There are 64MB RAM, 256MB FLASH, no X.
But I can run it correctly in Xterm in Ubuntu-20.04 VM. There are 2 framebuffer devices, /dev/fb0 and /dev/fb1. A GUI is running in the LCD display, so in this system, how can I run SDL application ?