We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1546

Summary: SDL_GL_LoadLibrary has error "Video subsystem has not been initialized" after SDL_Init(SDL_INIT_VIDEO) when SDL is dynamically loaded.
Product: SDL Reporter: Warren Wilkinson <warrenwilkinson>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED ENDOFLIFE QA Contact: Sam Lantinga <slouken>
Severity: major    
Priority: P2 CC: warrenwilkinson
Version: 1.2.15   
Hardware: x86_64   
OS: Linux   

Description Warren Wilkinson 2012-07-19 08:53:13 UTC
This code works when SDL is statically linked: a blank black window is displayed for 3 seconds.

(load "sdl")
(defconstant +width+ 1024)
(defconstant +height+ 768)
(defconstant +depth+ 32)

(or (= 0 (sdl::init (logior sdl::+init-video+ sdl::+init-audio+ sdl::+init-timer+)))
    (die "Unable to initialize SDL!"))

(or (= 0 (sdl::gl-load-library ffi:+null-cstring-pointer+))
    (die "Unable to load openGL!"))

(or (sdl::set-video-mode +width+ +height+ +depth+ sdl::+opengl+)
    (die "Unable to set video mode (~dx~d@~d)!" +width+ +height+ +depth+))

(sleep 3)
(sdl::kill)
(quit)

----

However, dynamically load SDL -- using dlopen("libSDL.so") -- doesn't work:

(setf *sdl* (sdl-dlopen "libSDL.so"))
(let ((flags (logior +init-video+ +init-audio+ +init-timer+)))
  (format t "~%INIT: Initializing (flags: ~a)" flags)
  (unless (= 0 (init *sdl* flags)) ;; call to C func SDL_Init
    (error "Some problem init SDL.")))

(format t "~%INIT: Load OpenGL Library...")
(let ((rv (gl-load-library *sdl* "libGL.so"))) ;; call to C func SDL_GL_LoadLibrary
  (unless (= 0 rv)
    (error "Some problem loading GL library: ~a (~s)" rv (get-error *sdl*))))

and the output is:

SDL: dlopen("libSDL.so")
INIT: Initializing (flags: 49)
SDL: dlsym("SDL_Init")
INIT: Load OpenGL Library...
SDL: dlsym("SDL_GL_LoadLibrary")
SDL: dlsym("SDL_GetError")
Condition of type: SIMPLE-ERROR
Some problem loading GL library: -1 ("Video subsystem has not been initialized")

If I comment out the openGL parts, this code can create a non-openGL SDL window.  Or I reorder, placing the call to SDL_GL_LoadLibrary(null) after SDL_SetVideoMode(height, width, depth, 0), then it will load the openGL library!


It seems as though the dynamically linked SDL initializes video differently or incompletely.
Comment 1 Ryan C. Gordon 2015-08-25 09:38:23 UTC
Hello, and sorry if you're getting several copies of this message by email, since we are closing many bugs at once here.

We have decided to mark all SDL 1.2-related bugs as RESOLVED ENDOFLIFE, as we don't intend to work on SDL 1.2 any further, but didn't want to mark a large quantity of bugs as RESOLVED WONTFIX, to clearly show what was left unattended to and make it easily searchable.

Our current focus is on SDL 2.0.

If you are still having problems with an ENDOFLIFE bug, your absolute best option is to move your program to SDL2, as it will likely fix the problem by default, and give you access to modern platforms and tons of super-cool new features.

Failing that, we _will_ accept small patches to fix these issues, and put them in revision control, although we do not intend to do any further official 1.2 releases.

Failing that, please feel free to contact me directly by email (icculus@icculus.org) and we'll try to find some way to help you out of your situation.

Thank you,
--ryan.