Distributing libraries with an application

Hi,
I’m confused about providing a copy of my application that doesn’t require the
libraries I use to already be installed in a particular location. If possible
I’d like to be able to provide either library files in the program directory, or
statically linked into the executable. In Windows this doesn’t seem to be too
hard… just package in the DLLs. But in Linux it seems like the libraries have
to be in hardcoded locations and it’s not possible to just have some library
files in a path relative to the executable.

I know this is kind of a general C question but I would appreciate any help with
respect to the SDL library, and other common libraries like SDL_image. I just
don’t want to have to have a copy of my program that people can just run, and
not have to separately install libraries to /usr/lib as root and stuff, or
compile them from source or anything like that.

Thanks, sorry if there’s an obvious solution

Nick

Nick H wrote:

I know this is kind of a general C question but I would appreciate any help with
respect to the SDL library, and other common libraries like SDL_image. I just
don’t want to have to have a copy of my program that people can just run, and
not have to separately install libraries to /usr/lib as root and stuff, or
compile them from source or anything like that.

Thanks, sorry if there’s an obvious solution

Common libraries is the key here. I don’t think there is any modern
(desktop) Linux distro that doesn’t package SDL. For all intents and
purposes, SDL is a part of the Linux desktop. Unless you are using
custom versions of the SDL libraries, you can be reasonably sure that
SDL and supporting libs are going to be present in /usr/lib (or
somewhere close). There really shouldn’t be any problem telling your
Linux users that they will need to have SDL installed. It’s just an apt,
yum, or emerge away.
That being said, you could package SDL dynamic libraries with your app.
Then include an executable script that will add your application lib
directory to LD_LIBRARY_PATH and call the real binary. Several
commercial linux apps do this. If you have any commercial Linux games
installed you can probably find a good example of how to do this.–
Max Watson <@Max_Watson>

Max Watson <max blackholesun.com> writes:

Common libraries is the key here.
That being said, you could package SDL dynamic libraries with your app.

Thanks for the advice Max, i’ll look into that.

Nick H