Derelict SDL2 library not loading on OS X

Mike Parker via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Dec 18 23:25:49 PST 2014


On 12/19/2014 9:58 AM, Joel wrote:
> [snip]

> derelict.util.exception.SymbolLoadException at derelict/util/exception.d(35):
> Failed to load symbol SDL_free from shared library
> /usr/local/lib/libSDL2.dylib

OK, the loader is finding libSDL2.dylib in /usr/local/lib where it 
expects it to be. Your error is that it cannot find the SDL_free 
function in the library. That indicates that the library version of SDL 
is 2.0.0 (SDL_free was added in 2.0.1) and you are using a branch of 
Derelict that is implemented against SDL 2.01 or higher.

You have three possible solutions here.

1) Use the 2.0.0 branch of Derelict.

2) Uninstall your 2.0.0 installation of SDL and use the latest version 
(along with the appropriate branch of DerelictSDL2 -- 2.0.1 for SDL 
2.0.1 and 2.0.2 for SDL 2.0.2 & 2.0.3 -- you shouldn't be using master).

3) Take advantage of Derelict's selective loading mechanism. This means 
you can use any branch of Derelict to load older versions of SDL2 by 
telling Derelict to not to throw exception on certain missing symbols. 
But that also means that you have to add a complete list of every symbol 
that was added between SDL 2.0.0 and whichever version corresponds to 
your version of Derelict. It's only feasible if you don't need the 
missing functions, but in that case you should go with option 1 anyway.

I strongly recommend the first option. Using the 2.0.0 branch allows you 
to load every version of SDL 2.0.x that has been or will be released. 
However, if you need certain functions that were added in later versions 
(such as SDL_GetBasePath which was added in 2.0.1), then you will need 
to use the 2.0.1 branch of Derelict and require version 2.0.1 at run time.

> I didn't put install with SDL2, libSDL2.dylib was in a different place
> than were I copied SDL2 (old installation?). And I couldn't get that to
> work either.

I'm not quite clear on what you're saying here. Is that you did not copy 
the version you compiled to /usr/local/lib/libSDL2.dylib and that the 
version you compiled also failed? At any rate, the options I presented 
above should help you sort it out.

[1] "Selective Symbol Loading" at the bottom of 
http://derelictorg.github.io/using.html


More information about the Digitalmars-d-learn mailing list