Jhenry726
Jhenry726

Reputation: 3

Getting a linux SDL2 program to run on a computer that does not have SDL2 installed?

I recently developed a small SDL2 game. The game ran fine on my computer because I have SDL, SDL_image, SDL_mixer, and SDL_ttf installed. However, everyone who downloaded the game did not have SDL2 and the extensions installed, so they could not run the application. How can I make the application usable even for people who don't have SDL2 installed?

Upvotes: 0

Views: 513

Answers (2)

blakelead
blakelead

Reputation: 1890

You could statically link you libs, that way no need to have SDL installed.

A way to do it :

g++ -o program [sources.cpp] -Wl,-Bstatic -lSDL2 -lSDL2_image \
-lSDL2_mixer -lSDL2_ttf -Wl,-Bdynamic [dynamically linked libs]

Note : If you use SDL2, you must use the SDL2 builds of peripheral libs otherwise you risk all kinds of errors.

Upvotes: 0

Quentin
Quentin

Reputation: 63114

You can pass the -rpath option to ld to specify search directories for dynamic libraries.

Using -rpath . (-Wl,-rpath . to pass it from GCC) will enable loading the libraries from the executable's directory. Just put the appropriate .so files there and they will be found.

Upvotes: 2

Related Questions