FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Can't load SDL Image/SDL ttf on Linux

 
Post new topic   Reply to topic     Forum Index -> Derelict
View previous topic :: View next topic  
Author Message
Andrej08



Joined: 31 Aug 2010
Posts: 51

PostPosted: Sun Jul 24, 2011 10:44 am    Post subject: Can't load SDL Image/SDL ttf on Linux Reply with quote

Running Ubuntu 10.10, x86.

I've extracted SDL, SDL ttf and SDL Image to my project's dir, compiled successfully but Derelict didn't manage to load the SDL Image library for some reason:

Quote:

andrej@andrej-VirtualBox:~/Desktop/dnehe/DNeonHelium/Samples$ ./lesson1
derelict.util.exception.SharedLibLoadException@derelict/util/exception.d(43): Failed to load one or more shared libraries:
libSDL_image.so - libSDL_image.so: cannot open shared object file: No such file or directory
libSDL_image-1.2.so - libSDL_image-1.2.so: cannot open shared object file: No such file or directory
libSDL_image-1.2.so.0 - libSDL_image-1.2.so.0: cannot open shared object file: No such file or directory
----------------


The two files for SDL image I've extracted are:
libSDL_image-1.2.so.0
libSDL_image-1.2.so.0.8.2

My command to compile was:
Quote:
dmd -g lesson1.d ../Derelict2/lib/libDerelictUtil.a ../Derelict2/lib/libDerelictGL.a ../Derelict2/lib/libDerelictGLU.a ../Derelict2/lib/libDerelictSDL.a ../Derelict2/lib/libDerelictSDLImage.a ../Derelict2/lib/libDerelictSDLttf.a -I../Derelict2/import -L-ldl -L-lDerelictGL -L-lDerelictGLU -L-lDerelictSDLImage -L-lDerelictSDLttf -L-lDerelictSDL -L-lDerelictUtil -L-L../Derelict2/lib/


Any idea why it won't load them? IIUC they should load without problems if they're in the current directory of the project. I get the same thing with the ttf libraries, and I've extracted those to the directory too.

It does manage to load the SDL and OpenGL library itself, SDL was also extracted in the local directory. But then I get some funky runtime error:
Quote:
OpenGL Error: Can't patch size is too small.(glXCopyContext)


That could easily be related to some 3D acceleration problem inside the Virtualbox window (yeah I'm on a VM), since the sample works fine with SDL on Windows.
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Sun Jul 24, 2011 10:46 pm    Post subject: Reply with quote

dlopen (which Derelict uses internally to load shared libs on Posix systems) is not guaranteed to search the current working directory for a shared library. It searches the directories specified in the environment variable LD_LIBRARY_PATH. That *should* include the current working directory ('.'). The first thing I would do is check that your LD_LIBRARY_PATH is indeed configured that way.

The next thing I would try is to specify the library name in the call to the load method:

DerelictSDLImage.load("./libSDL_image-1.2.so.0.8.2");

Try it both with and without the './'. Maybe try the .0 version as well.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
Andrej08



Joined: 31 Aug 2010
Posts: 51

PostPosted: Mon Jul 25, 2011 6:49 am    Post subject: Reply with quote

Thanks, you were right about that. In fact LD_LIBRARY_PATH was empty. I assumed EXPORT would permanently add an environment variable, but it seems I was wrong after reading this: https://help.ubuntu.com/community/EnvironmentVariables.

Btw, is there a way to programmatically make dlopen() search the current directory? I mean how would you distribute an app that has the shared libs in the local directory without messing with the user's LD_LIBRARY_PATH?
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Tue Jul 26, 2011 2:43 am    Post subject: Reply with quote

You'd have to pass the lib names directly to the Derelict*.load methods yourself, prepending a "./". If you need to account for more than one possible version, you can pass a string of multiple, comma-separated library names.

And actually, there is an enhancement request to allow the setting of a directory, or several paths, that can be prepended automatically by the Derelict loader. One of these days...
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Derelict All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group