I was having a problem getting one of my programs that uses SDL to compile so to fix it I reinstalled SDL2 and SDL2Image following this link: https://solarianprogrammer.com/2015/01/22/raspberry-pi-raspbian-getting-started-sdl-2/ I used this link before and have created windows and renderers successfully. Now the program compiles and runs but I get the error
SDL Initialization failed no available video device
When initializing SDL.
I am not sure what video system is being used because the configuration command disables mir wayland x11 and opengl. The tutorial says something about forcing opengl es.
FOR SDL2:
I downloaded and unpacked the tar file into my home directory, then configured using this command:
../configure --disable-pulseaudio --disable-esd --disable-video-mir --disable-video-wayland --disable-video-x11 --disable-video-opengl
The output was:
SDL2 Configure Summary:
Building Shared Libraries
Building Static Libraries
Enabled modules : atomic audio video render events joystick haptic power filesystem threads timers file loadso cpuinfo assembly
Assembly Math :
Audio drivers : disk dummy oss alsa(dynamic) sndio
Video drivers : dummy opengl_es1 opengl_es2
Input drivers : linuxev linuxkd
Using libudev : YES
Using dbus : YES
I then used: make -j 4
then: sudo make install
FOR SDL2_Image:
I configured with: ../configure, there was no summary
then: make -j 4
then: sudo make install
I just tried the test program that the tutorial link gives and it executes and displays the image properly, here is the code for initializing things:
int main(int argc, char** argv) {
// Initialize SDL
check_error_sdl(SDL_Init(SDL_INIT_VIDEO) != 0, "Unable to initialize SDL");
// Create and initialize a 800x600 window
SDL_Window* window = SDL_CreateWindow("Test SDL 2", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
800, 600, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL);
check_error_sdl(window == nullptr, "Unable to create window");
// Create and initialize a hardware accelerated renderer that will be refreshed in sync with your monitor (at approx. 60 Hz)
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
check_error_sdl(renderer == nullptr, "Unable to create a renderer");
// Set the default renderer color to corn blue
SDL_SetRenderDrawColor(renderer, 100, 149, 237, 255);
// Initialize SDL_img
int flags=IMG_INIT_JPG | IMG_INIT_PNG;
int initted = IMG_Init(flags);
check_error_sdl_img((initted & flags) != flags, "Unable to initialize SDL_image");
I copied that code over exactly to my code and I no longer get the SDL Init. failed but I get these errors:
Unable to initialize SDL_image Invalid renderer
Unable to create texture Invalid renderer
Unable to create texture Invalid renderer
Unable to create texture Invalid renderer
It is a 1-to-1 copy of this test file so I'm not sure what could be going on. Any suggesstions?
UPDATE:
After recompiling the test program it no longer works either and gives the SDL Init failed error. I compiled with this line:
g++ -std=c++0x -Wall -pedantic sdl2_test.cpp -o sdl2_test `sdl2-config --cflags --libs` -lSDL2_image
I reconfigured and installed, instead of configuring with:
../configure --disable-pulseaudio --disable-esd --disable-video-mir --disable-video-wayland --disable-video-x11 --disable-video-opengl
I simply did:
../configure
Not sure if this will introduce other problems down the road but for now the images display and keyboard input can be captured.