Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Hope you like reading ldd output!

A week ago I was CC'd in on a thread about Linux packaging, and how to avoid doing it the wrong way (i.e. RPM, Deb, etc.). I've always used MojoSetup and I've never forced distributions to do any additional work, but this is still a new concept to a lot of people. Additionally, Amos suggested that I expand on Itch's FNA appendix, so here's a guide on how I package my games.

This is a bit of an expansion on my MAGFest 2016 presentation, which you can find here:

I would recommend looking at that first! After that, read on...

On any operating system you should always assume one thing: Absolutely none of your game's dependencies will be on the system except for the C runtime and a graphics driver (hopefully it's a new one, but that's another story). For whatever reason this surprises a lot of people, particularly Windows developers that already do this on Windows! This may be the result of people discovering things like apt and dnf, where Linux users can grab software via repositories and not have to pull in a giant blob of things from the web whenever they do clean installs, or what have you.

The first mistake you can make is thinking that you need to integrate the package manager into your game.

The software you grab from a repository is NOT the same thing as what you grab from a website! These repositories fulfill a very important role, and it actually has very little to do with convenience. They're actually doing something much more important: ensuring compatibility across the entire system and everything that might run on it. The way this is done is by self-compiling everything:

So when Fedora updates Mono, for example...

... they're not grabbing a blob from the Mono project website, they're pulling the source in and building against Fedora's system libraries, which were also self-built, and then building everything that depends on Mono against the new version, all with an ungodly amount of checks, tests, and all sorts of things that make build engineers sweat with joy.

Your game is not doing any of that, and it's certainly not doing it for every single distribution. This is likely because A: your game is proprietary, B: you probably just want to type make once and be done with it like an Earth-dwelling being, and C: you don't even have a grasp of just how many distributions are out there, and that's just limiting it to the ones that exist today that will be running your game.

Sounds like an insane ecosystem to support, but guess what: Just treat Linux deps like you do Windows deps and all of this goes away! With this in mind, let's look at an example.

Here's the dependency tree for Super Hexagon, generated by ldd:

[flibitijibibo@flibitTower data]$ ldd x86_64/superhexagon.x86_64 (0x00007ffd30363000) => /lib64/ (0x00007f434a094000) => /lib64/ (0x00007f4349e23000) => x86_64/ (0x00007f4349b00000) => x86_64/ (0x00000031f7e00000) => x86_64/ (0x00007f4349855000) => x86_64/ (0x0000003d47200000) => /lib64/ (0x00007f43494d3000) => /lib64/ (0x00007f43491d0000) => /lib64/ (0x00007f4348fb9000) => /lib64/ (0x00007f4348d9c000) => /lib64/ (0x00007f43489da000) => /lib64/ (0x00007f43487d6000) => /lib64/ (0x00007f43485a5000) => /lib64/ (0x00007f43482bb000) => /lib64/ (0x00007f4347f7b000) => /lib64/ (0x00007f4347d73000) => /usr/lib64/ (0x00007f4347b45000) => /usr/lib64/ (0x00007f434793e000)
	/lib64/ (0x00005651c1fe0000) => /lib64/ (0x00007f434772b000) => /lib64/ (0x00007f4347509000) => /lib64/ (0x00007f4347304000)

This might seem daunting at first, but that's because you didn't build this game. I did, and I know exactly what I linked to. The link line looks like this:

g++ -O2 -pthread (SECRETS) -o x86_64/superhexagon.x86_64 (STATICLIBS) -lGL -lGLU -lSDL2 -lGLEW -lopenal -lvorbisfile

Here's what we care about:

-lGL -lGLU -lSDL2 -lGLEW -lopenal -lvorbisfile

-lGL and -lGLU are pretty self-explanatory; obviously you don't need to ship OpenGL drivers, so you can skip those outright. But SDL2, GLEW, OpenAL, and Vorbisfile are definitely DLLs you would ship on Windows (well, maybe you statically link GLEW, but you get the idea).

But what's all that other crap up there? Even after trimming down our stuff, we're left with this: => /lib64/ (0x00007f43494d3000) => /lib64/ (0x00007f43491d0000) => /lib64/ (0x00007f4348fb9000) => /lib64/ (0x00007f4348d9c000) => /lib64/ (0x00007f43489da000) => /lib64/ (0x00007f43487d6000) => /lib64/ (0x00007f43485a5000) => /lib64/ (0x00007f43482bb000) => /lib64/ (0x00007f4347f7b000) => /lib64/ (0x00007f4347d73000) => /usr/lib64/ (0x00007f4347b45000) => /usr/lib64/ (0x00007f434793e000)
	/lib64/ (0x00005651c1fe0000) => /lib64/ (0x00007f434772b000) => /lib64/ (0x00007f4347509000) => /lib64/ (0x00007f4347304000)

That's still a lot of junk, and you may not know what you need to ship...

The easy way to check is to just ldd your own dependencies and see where it leads. I'll give you a quick hint and say you can immediately skip the C/C++ runtime and friends, AKA these guys:

  • libc
  • libm
  • libdl
  • librt
  • libgcc_s
  • libstdc++(*)
  • libpthread
  • Those weird Linux objects (linux-vdso, ld-linux, etc.)

Already we're down to this: => /lib64/ (0x00007f43485a5000) => /lib64/ (0x00007f43482bb000) => /lib64/ (0x00007f4347f7b000) => /usr/lib64/ (0x00007f4347b45000) => /usr/lib64/ (0x00007f434793e000) => /lib64/ (0x00007f434772b000) => /lib64/ (0x00007f4347509000) => /lib64/ (0x00007f4347304000)

We've not even looked at our dependencies yet and already it's looking good! But let's start checking those out. Here's libGL and libGLU:

[flibitijibibo@flibitTower x86_64]$ ldd /usr/lib64/ (0x00007ffc8a6c7000) => /lib64/ (0x00007f095108b000) => /lib64/ (0x00007f0950e59000) => /lib64/ (0x00007f0950b70000) => /lib64/ (0x00007f09507af000)
	/lib64/ (0x000055ca83bf3000) => /lib64/ (0x00007f095046e000) => /lib64/ (0x00007f095025c000) => /lib64/ (0x00007f095003a000) => /lib64/ (0x00007f094fe35000)
[flibitijibibo@flibitTower x86_64]$ ldd /usr/lib64/ (0x00007fff1f18d000) => /lib64/ (0x00007ff4433d4000) => /lib64/ (0x00007ff443051000) => /lib64/ (0x00007ff442d4f000) => /lib64/ (0x00007ff44298e000) => /lib64/ (0x00007ff442776000) => /lib64/ (0x00007ff442572000) => /lib64/ (0x00007ff442341000) => /lib64/ (0x00007ff442057000)
	/lib64/ (0x00005581f1329000) => /lib64/ (0x00007ff441d17000) => /lib64/ (0x00007ff441b05000) => /lib64/ (0x00007ff4418e2000) => /lib64/ (0x00007ff4416de000)

Right away you see libGLX, libGLdispatch, and all those libX* libs. These were needed for the driver so those can be assumed as available, and thus we can narrow it down further: => /usr/lib64/ (0x00007f4347b45000) => /usr/lib64/ (0x00007f434793e000)

All that's left is Ogg and Vorbis, and I'll hazard a guess that you know where these guys came from:

[flibitijibibo@flibitTower x86_64]$ ldd (0x00007ffd2b34b000) => /usr/lib64/ (0x00007f007c5d2000) => /usr/lib64/ (0x00007f007c3ca000) => /usr/lib64/ (0x00007f007c009000) => /usr/lib64/ (0x00007f007bd07000)
	/lib64/ (0x000056162ecab000)

So along with Vorbisfile we need to ship Ogg and Vorbis too. Big surprise, right? Basically anything that's not a standard runtime lib and not something that was needed by the driver needs to go into your game. There are very few exceptions to this rule - for example, I'm pretty sure a Linux machine without zlib is a work of fiction at this point. But libpng, which uses zlib, should probably be included with your game due to the various versions of that lib (1.2, 1.5, etc.).

At the end of the day, that giant ldd we started with actually looks like this in the official shipping version of Super Hexagon:

[flibitijibibo@flibitTower data]$ ls x86_64/

This all might seem complicated, but keep in mind that this is only as complicated as your dependency tree is. If you use libraries that are also conscious of this you'll be fine, but not everyone is like this. So unfortunately, all of you using stuff like SFML or even Chromium are in for a real treat:

[flibitijibibo@flibitTower lib64]$ ldd (0x00007ffc1fd84000) => /lib64/ (0x00007f4ff5ade000) => /lib64/ (0x00007f4ff58d9000) => /lib64/ (0x00007f4ff56d5000) => /lib64/ (0x00007f4ff5483000) => /lib64/ (0x00007f4ff5149000) => /lib64/ (0x00007f4ff4f05000) => /lib64/ (0x00007f4ff4c5b000) => /lib64/ (0x00007f4ff4a4d000) => /lib64/ (0x00007f4ff4724000) => /lib64/ (0x00007f4ff44d9000) => /lib64/ (0x00007f4ff41d6000) => /lib64/ (0x00007f4ff3e96000) => /lib64/ (0x00007f4ff3c86000) => /lib64/ (0x00007f4ff3a82000) => /lib64/ (0x00007f4ff3870000) => /lib64/ (0x00007f4ff3547000) => /lib64/ (0x00007f4ff3318000) => /lib64/ (0x00007f4ff30f1000) => /lib64/ (0x00007f4ff2eb2000) => /lib64/ (0x00007f4ff2bba000) => /lib64/ (0x00007f4ff29b7000) => /lib64/ (0x00007f4ff27b1000) => /lib64/ (0x00007f4ff25aa000) => /lib64/ (0x00007f4ff2378000) => /lib64/ (0x00007f4ff2152000) => /lib64/ (0x00007f4ff1f46000) => /lib64/ (0x00007f4ff1d3b000) => /lib64/ (0x00007f4ff1b37000) => /lib64/ (0x00007f4ff192b000) => /lib64/ (0x00007f4ff1701000) => /lib64/ (0x00007f4ff14b1000) => /lib64/ (0x00007f4ff1293000) => /lib64/ (0x00007f4ff100a000) => /lib64/ (0x00007f4ff0c88000) => /lib64/ (0x00007f4ff0a70000) => /lib64/ (0x00007f4ff06af000)
	/lib64/ (0x000055b337c66000) => /lib64/ (0x00007f4ff04a7000) => /lib64/ (0x00007f4ff0290000) => /lib64/ (0x00007f4ff0080000) => /lib64/ (0x00007f4fefe4d000) => /lib64/ (0x00007f4fefc36000) => /lib64/ (0x00007f4fefa2d000) => /lib64/ (0x00007f4fef82b000) => /lib64/ (0x00007f4fef5c8000) => /lib64/ (0x00007f4fef321000) => /lib64/ (0x00007f4fef11d000) => /lib64/ (0x00007f4feef18000) => /lib64/ (0x00007f4feed0e000) => /lib64/ (0x00007f4feeaec000) => /lib64/ (0x00007f4fee85c000) => /lib64/ (0x00007f4fee657000) => /lib64/ (0x00007f4fee452000) => /lib64/ (0x00007f4fee227000) => /lib64/ (0x00007f4fee19e000) => /lib64/ (0x00007f4fedf50000) => /lib64/ (0x00007f4fedc68000) => /lib64/ (0x00007f4feda35000) => /lib64/ (0x00007f4fed831000) => /lib64/ (0x00007f4fed4fd000) => /lib64/ (0x00007f4fed2ef000) => /lib64/ (0x00007f4fed0de000) => /lib64/ (0x00007f4fecea8000) => /lib64/ (0x00007f4fecc9f000) => /lib64/ (0x00007f4feca73000) => /lib64/ (0x00007f4fec789000) => /lib64/ (0x00007f4fec585000) => /lib64/ (0x00007f4fec354000) => /lib64/ (0x00007f4febfd3000) => /lib64/ (0x00007f4febdb0000) => /lib64/ (0x00007f4febb95000) => /lib64/ (0x00007f4feb96e000) => /lib64/ (0x00007f4feb689000) => /lib64/ (0x00007f4feb475000) => /lib64/ (0x00007f4feb22a000) => /lib64/ (0x00007f4feb025000) => /lib64/ (0x00007f4feae16000) => /lib64/ (0x00007f4feac11000) => /lib64/ (0x00007f4fea9ab000) => /lib64/ (0x00007f4fea776000) => /lib64/ (0x00007f4fea563000) => /lib64/ (0x00007f4fea32c000) => /lib64/ (0x00007f4fea0ff000) => /lib64/ (0x00007f4fe9e86000) => /lib64/ (0x00007f4fe9c83000) => /lib64/ (0x00007f4fe9a12000) => /lib64/ (0x00007f4fe97fa000) => /lib64/ (0x00007f4fe95f3000)

If you really hated reading this and want to avoid doing anything like this at all costs, your solution is to simply calm down on the dependency tree. Use OS portability libs like SDL which only depend on the C runtime (or in the case of Windows, not even that). Use SDL_GL_GetProcAddress instead of linking to libGL directly (for that matter, don't use GLU or GLEW). Use stb_image or LodePNG instead of linking to libjpeg, libpng, etc. Use something like stb_vorbis instead of libvorbisfile. Don't use GTK/Qt/wx at all. You can even find libs like miniz which can replace seemingly tiny dependencies like zlib! These are really tiny things you can do to get your dependency tree looking sparkling clean without having to do any real work at all, and it makes your game super portable as well.

Now that we know what files we need to ship, where do we put them? Is it just like throwing DLLs next to the EXE?

Linux library paths are a little bit strange, but this can work to our advantage. Odds are you're shipping both 32-bit and 64-bit, and you probably don't want to make 2 packages just for each architecture. RPM/Deb might force you to do this, but we're better than that. We can bundle 32/64-bit together at once simply by using an executable script instead of directly launching the executable binary. It'll look something like this:

	- GameName <- This is our script!
	- Content.blob
	- x86/
		- gamename.x86
	- x86_64/
		- gamename.x86_64

And the script will look something like this:

And that's it! We move to the location of the game, determine which architecture to pick, and add the real executable folder to the library search path before launching the binary.

There is only one thing you must be careful about: If you're doing most of your deployment from Windows, BE SURE that you did not save this script with Windows line endings! Windows is fantastically stupid and uses '\r\n' as a new line instead of just '\n', and this will rightfully confuse the system when trying to read the script. Very often I get reports from FNA developers that miss this and as a result, none of their players can play the game.

From here you're totally done putting the game together; this would be exactly what goes into your SteamPipe build folder, and you could throw this into a .tar.gz or .tar.bz2 file and be done with it. But we want an installer, right?

Finally we can talk about MojoSetup, which is probably a MUCH smaller part of packaging than you thought. Here's how it works: Grab this archive here:

Extract it somewhere, navigate to the location in a terminal, and run this:

./ examplegame

Congratulations, you just made a MojoSetup package. Seriously, that's it. Run ./examplegame-installer and check it out!

What you're looking at is a self-extracting zipfile (try it: unzip examplegame-installer) with both graphical and command-line interfaces, which allow users to install wherever they have permission to write while NEVER touching the system's package database, and it will automatically generate local desktop icons and an uninstaller that never leaves a footprint, while also prominently showing them the README right at the beginning of the install process.

And you probably wanted to ship a .deb file. Ha ha.

Getting this to work with your game is as trivial as just ripping off the examplegame/ folder. Simply edit the files for the needs of your game's title, description, etc. and copy your game folder into data/, and your packaging environment is complete.

The two files that are notably important are the example FEZ.bmp and Linux.README. For that particular bmp, you can use PNG if you want; it just needs to be large enough to work as a high-resolution desktop icon (which you should already have a VERY large version of if you ship for the Mac already). The Linux.README can have whatever you like inside, but that's the format that I've always used for my games.

From there, just upload the package and users can download your game, installing or unzipping as they please, and you'll never have to fight the distro's package manager to get users started. If you ship as often as I do, this matters a LOT. More importantly, being able to keep the build environment static is important too - having to do anything more than copying data and running ./ becomes a HUGE pain when you have a large library of games to maintain over a period of many MANY years (and counting). Do whatever you can to keep your packaging process small!

MojoSetup's been a standard for myself and for many long-time Linux game developers - its roots go back to the late 1990s and Loki Software! I hope that it will be your standard as well.

(*) - At one point it was a tradition to ship with libstdc++ due to horrible ABI incompatibilities, but this appears to have gotten less horrible over the last few years, and some distributors like Valve will actually recommend NOT shipping with it.

Copy link

faho commented Jun 17, 2016

At one point it was a tradition to ship with libstdc++ due to horrible ABI incompatibilities, but this appears to have gotten less horrible over the last few years, and some distributors like Valve will actually recommend NOT shipping with it.

Ummh... Valve actually ships libstdc++ in the steam runtime, and it's caused a bit of incompatibility (because the free graphics drivers use it, and you can't have two of those in the same process at the same time IIRC). See ValveSoftware/steam-runtime#13.


Copy link

Ancurio commented Jun 17, 2016

Great writeup, just curious; why did you use ldd instead of checking the linked libs directly with something like readelf -d?


Copy link

flibitijibibo commented Jun 17, 2016

@Ancurio: No reason whatsoever!

@faho: The Steam runtime is a whole different world of pain... this is partially why I include my libs minus libstdc++.


Copy link

mmozeiko commented Jun 17, 2016

What about GLIBC version compatibility? If you are using system then you might get older version that doesn't have symbols you need.


Copy link

flibitijibibo commented Jun 18, 2016

@mmozeiko glibc version compat is a whole different story... One that's in the middle of changing since 2.15's getting old and my buildbot needs updating.


Copy link

Justinzobel commented Jun 19, 2016

@faho yeah Steam ships ancient runtimes that are from Ubuntu 12.04 iirc.


Copy link

fasterthanlime commented Jul 16, 2016

@mmozeiko The easiest fix to that is (for me) to compile using the reasonably-oldest distribution you can find. For me that's Debian 7.5.


Copy link

probonopd commented Oct 8, 2016

@flibitijibibo very well said. Actually your approach is very similar to making an AppDir, which in the end you can optionally turn into an AppImage.

I have been working on tools to make this easier, e.g.,

Happy to hear your thoughts, maybe you'd like to chime in on


Copy link

probonopd commented Oct 8, 2016

@fasterthanlime I agree, my recommendation currently is CentOS 6, debian oldstable, or something like that.


Copy link

Pshemas commented Nov 12, 2016

Thank you for writing this Ethan. I'm not a programmer , so I'm fairly inexperienced at this ... so ... I've flipped through mojosetup web pages and I wonder - is it possible to make an installer with it that would ask user for password (grant "sudoer" permissions) when trying to install to a folder that needs additional permissions? I'm thinking about packaging some assets for an app in a way that wouldn't require the user to hassle with command line, choosing the right folder , sudo-ing and so on (and sadly with default setup most people seem to have some files will need to go to /usr/share/appname/assets).


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment