5

I have a small SDL 2.0 program (detailed below) that refuses to give me a window, complaining about not being able to initialize its OpenGL ES library.

Program:

#include "bcm_host.h"

#include <SDL.h>
#include <GLES2/gl2.h>
#include <stdlib.h>

int main() {
        bcm_host_init();

        SDL_Init(SDL_INIT_VIDEO);
        SDL_Window *window = SDL_CreateWindow("Test", 0, 0, 400, 300, 0);
        if (window == NULL) {
                fprintf(stderr, "%s\n", SDL_GetError());
                return 1;
        }

        return 0;
}

Output:

Could not initialize OpenGL / GLES library

What's going on? Shouldn't bcm_host_init() be all that I need to get a normal SDL 2.0 program to run on the Pi? What else do I need to do?

2
  • I have the same error (I don't use bcm_host_init function). The code is compiled right in my raspberry, but I cannot run it. Best regards
    – user23172
    Dec 10, 2014 at 21:49
  • Do you have at least gpu_mem=128 in /boot/config.txt to allow for 3D acceleration?
    – Fred
    Jan 25, 2015 at 11:35

1 Answer 1

3

I had the same problem and the culprit was mesa-common-dev. Try removing it using

% sudo apt-get remove mesa-common-dev

A new round of ./configure && make && sudo make install made my SDL2 program run.

1
  • Thanks @Johan-Kanflo for your answer. I had similar problem with Urho3D on RPi 3, which your answer solved it. Thanks.
    – Omid1989
    Oct 16, 2016 at 11:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.