How can I make it as easy as possible for another Linux user to play my compiled Linux game?

How can I make it as easy as possible for another Linux user to play my compiled Linux game?

Should the player run all the commands below?

sudo apt-get install libsdl2-2.0

sudo apt-cache search libsdl2-image
sudo apt-get install libsdl2-image-dev

sudo apt-cache search libsdl2-mixer
sudo apt-get install libsdl2-mixer-dev

And then go to the game folder and type

./MyGame

to run my game?

Yes, installing something without the user knowing is not really good, how you wrote it is how it supposed to be done, so that the user knows what libraries one had installed. At least the user should be asked whether to install these libraries, but then of course every question makes it more difficult for the beginners, when one doesn’t really know whether to answer yes or no. One may add an advice maybe, if not sure say yes.

I would prefer to use a python script for all installing and building, both in Linux and Windows. I’m a minimalist though, some may not find it advanced enough, but simple things often work the best. It is simpler and also more flexible. So that the user just runs that script to install everything and build, maybe also run, so all one has to do to run the game after it is installed, is to run that script. But to not do everything blindly, the script may have to ask some questions.

deb packages have dependencies though, so if you distribute it as a deb package, maybe just add dependencies. But dependencies are also like a kind of blind installation, the question is whether they are proper to add to just a game.

The user really shouldn’t need the -dev packages if they use binaries that you provide.
Demanding that SDL2 is installed on a users system is reasonable (if you don’t need any SDL2 feature that has only been added in a recent version).
For sdl2-image and sdl2-mixer I’m not so sure, might be nice to bundle them (AND THEIR DEPENDENCIES).

BTW, I wrote a blogpost about creating portable binaries for Linux some years ago, still relevant: https://blog.gibson.sh/2017/11/26/creating-portable-linux-binaries/

1 Like

Thanks a lot Daniel. Your blogpost is very informative !

How can I list the dependencies of my game recursively to list its dependencies, the dependencies of its dependencies… ? How far should I follow the dependency links?

1 Like

I’m glad you like the blogpost!

The lddtree tool tells you what your direct dependencies are and what those depend on etc, it’s used like lddtree YourProgram. On debian-derivatives like Ubuntu it’s in the pax-utils package

BTW, for reducing dependencies you could try if my SDL_stbimage.h can replace SDL_Image for you - its only dependencies are SDL2 and stb_image.h, so no additional DLL’s/.so’s. It supports several image file formats (but not as many as SDL_Image), and unlike SDL_Image it doesn’t support writing images.

Oh BTW, keep in mind that my blogpost is three years old, so you can probably assume newer versions of libgcc and libstdc++ on users systems (I assumed GCC 4.7 as a minimum), you can certainly assume the ones of GCC 4.9 to be available, probably GCC 5.x is safe as well - so if your game can be built with that compiler version you probably don’t need the wrapper.

lddtree works great and its output is more readable than ldd.

Thanks for the link to SDL_stbimage. It certainly is a good alternative to SDL_image as I don’t write images.