Installation of binary apps on linux

I’d like to make a binary installer for a game I wrote on linux, this
game obviously use sdl :slight_smile:

I’m just wondering if there are some guides or tutorial about how to
perform the following steps, obviously I’ve googled around a few hours
before posting here, but with almost not useful results…:

  • Obtain a compressed “clickable” installer that runs with almost any
    libc version.

(loki installer + makeself?)

  • Be able to add KDE / Gnome menu entry in the correct way.

(no idea at all about this, I’ve seen that many distributions place the
small xml file used to describe the menu entry in different places, also
the format is slightly different in kde & gnome…, freedesktops may helps?)

  • Be sure that the game uses my libraries and not the ones provided on
    the user machine (to avoid compatibility issues).

(export LD_LIBRARY_PATH=./mylibs:$LD_LIBRARY_PATH in the game startup
script is enough?)

I’d like to make a binary installer for a game I wrote on linux, this
game obviously use sdl :slight_smile:

I’m just wondering if there are some guides or tutorial about how to
perform the following steps, obviously I’ve googled around a few hours
before posting here, but with almost not useful results…:

No tutorials that I’m aware of. (I’ve been thinking about writing one,
though. I seem to be answering this kind of questions pretty often as
of late =))

  • Obtain a compressed “clickable” installer that runs with almost any
    libc version.

(loki installer + makeself?)

Loki+makeself works fine, but Loki is severely outdated. Autopackage
seems more up-to-date, but has some flaws like not being entirely self-
contained (you either need an internet connection at install time, or
more files) and no possibility of showing a README/EULA, etc. If you’re
not just interested in free stuff, I’ve heard good things about the
Bitrock installer. Loki is still the most feature-rich one, though.
But, as I said, outdated. Sigh.

Anyway, even if you get an installer you can live with, the “runs with
almost any libc version” might be trickier than you think. I guess it
depends on your audience, but imo supporting ancient glibc versions is
more trouble than it’s worth. I’ve settled for 2.3 and higher myself,
which is still old-ish (2.3 came out in 2002 sometime, I think), and
doesn’t require too many hacks to get working. In any case, there’s
basically two ways to do this:

  1. Use an old glibc when linking.

Should be simple, right ? Unfortunately old glibcs doesn’t compile with
newer gccs. There are ways around this (google for crosstool), but you
might still run into compatibility issues. I used to do this with DROD,
but have now moved on to…

  1. Use a newer glibc, but prevent linking with too new symbol versions.

Unfortunately there’s no options you can pass to gcc to make it do this
the easy way. In stead, you’ll have to override the symbols manually
using assembler directives. This is a bit of a hack, but it seems to
work. Autopackage has some tools that can help with this (see
http://autopackage.org/aptools.html), or you can use a similar tool
I made that generates a similar header for you in a somewhat different
way (http://delirare.com/files/gensymoverride). Once you’ve got your
header, you can include it as the first argument to gcc when compiling
stuff, using the -include option. That’ll give you glibc compatibility,
but remember that you’ll have to compile any libraries you include this
way as well. And the installer, if you compile that.

Also, try to make the libraries you include as compatible as possible.
To stray on-topic a bit, for SDL you’ll want to include support for arts,
esd and alsa so that people will get sound no matter what they use, but
you don’t want to require these libraries since not all of them are
installed everywhere. Thankfully SDL supports run-time dynamic linking
for this purpose, which you can enable in configure. You might also
want to include as many video drivers as you can without adding more
dependencies. Also, using the -Wl,–as-needed switch when linking
(with newer gcc’s) will make sure that only libraries that are actually
used directly by what you link are required. Nice to get rid of that
spurious SDL libstdc++ dependency that pops up sometimes. (Using this
might make dependencies you need to include harder to spot if you’re
just using ‘objdump -x file | grep NEEDED’. Use LD_LIBRARY_PATH with
ldd on the executable as well).

Do NOT statically link glibc. Don’t include it in your installer either.
Get rid of libgcc_s.so with -static-libgcc. If your game is C++, you can
link libstdc++ statically (this is actually required in addition to using
-static-libgcc if you want to statically link libgcc with C++ code), but
doing this means exceptions won’t work correctly across dynamically linked
files. Rule of thumb is, if you’re statically linking libstdc++, you
should statically link everything that uses libstdc++ into the same
file. To statically link libstdc++ properly, get the .a location with
’g++ -print-file-name=libstdc++.a’ and pass this as the final argument
when linking.

  • Be able to add KDE / Gnome menu entry in the correct way.

(no idea at all about this, I’ve seen that many distributions place the
small xml file used to describe the menu entry in different places, also
the format is slightly different in kde & gnome…, freedesktops may
helps?)

Well, it depends how old distributions you want to support. Loki Setup,
for example, does things the old way, which still kinda works, but menu
entries tend to get lumped into the “Other” menu in stead of Games on
some newer systems. Going with the freedesktop.org standards is a better
idea these days. It obviously won’t work on systems that came out before
the standards were in widespread use (which should at least be a couple
years ago by now ?), but it’ll work correctly on what’s out there today.

http://www.freedesktop.org/wiki/Standards/desktop-entry-spec
http://www.freedesktop.org/wiki/Standards/menu-spec
http://www.freedesktop.org/wiki/Standards/basedir-spec
  • Be sure that the game uses my libraries and not the ones provided on
    the user machine (to avoid compatibility issues).

(export LD_LIBRARY_PATH=./mylibs:$LD_LIBRARY_PATH in the game startup
script is enough?)

Usually, yes, assuming the shell supports the export command, you’re in
the right current directory when executing the game, the libraries are
built correctly, and that the libraries in ./mylibs does not contain
any RPATHs, since libraries with RPATH won’t work in any other locations
than the one specified in their RPATH. You can check for RPATH with
objdump -x. If any libraries has it set, you need to remove it somehow
(the easiest way is to just rebuild them after fixing the config and/or
makefiles or libtool).

Btw, you can also use RPATH on the executable to specify the location
of the libraries in stead of using LD_LIBRARY_PATH. If you use an
absolute rpath, you don’t need the wrapper anymore, but on the other
hand you’ll only be able to install the libraries in one hard-coded
location (= bad) unless you modify the executable at install-time…
The alternative is a relative rpath, but that still requires the
current directory to be set correctly, so you’ll need the wrapper
again. The LD_LIBRARY_PATH way is more convenient.

Well, that was a bit of an overview, at least. Hope it helps =)

~ GerryOn Fri, 01 Dec 2006 09:40:27 +0100, Gabriele Greco <gabriele.greco at darts.it> wrote:

Gabriele Greco wrote:

  • Be able to add KDE / Gnome menu entry in the correct way.

(no idea at all about this, I’ve seen that many distributions place the
small xml file used to describe the menu entry in different places, also
the format is slightly different in kde & gnome…, freedesktops may helps?)

There’s the ‘portland initiative’:
http://portland.freedesktop.org/wiki/

and it’s implementation in xdg-utils:
http://portland.freedesktop.org/xdg-utils-1.0/

tom

  • Obtain a compressed “clickable” installer that runs with almost any
    libc version.

(loki installer + makeself?)

That’s what I use. You’ll probably have to do some tapdancing to make
sure you build with a glibc that works right everywhere, and link with
only what you need, etc. You might do well to just extract Google
Earth’s installer and reuse the binaries from it…a LOT of time was
spent customizing and automating the build of those binaries, including
a gtk+2 installer that falls back to a statically linked gtk1 installer
if there are dependency issues.

I’m currently using a dedicated build box with Ubuntu 5.10/x86 to keep
glibc dependencies sane. Before that, I was building on Red Hat 6.0 (!),
but the NPTL issues finally forced me to something more modern. You’re
probably good for a few years before big glibc changes or migration away
from ELF or some other crazy thing helpfully breaks your binary
again…which is much better than it was even five years ago, where you
either had two separate binaries, or lost ABI compatibility every six
months, or both.

It’s a bit of a dark art, but once you get it working, it works
everywhere. Make sure you build SDL so it dynamically loads everything
it can (including Xlib, esound, arts, nas, etc). You can have an
extremely functional libSDL that only explicitly links against glibc and
makes good decisions at runtime. The dynamic X11 support needs you to
build SDL with gcc4.

  • Be able to add KDE / Gnome menu entry in the correct way.

(no idea at all about this, I’ve seen that many distributions place the
small xml file used to describe the menu entry in different places, also
the format is slightly different in kde & gnome…, freedesktops may helps?)

http://portland.freedesktop.org/wiki/

There’s a script there for installing desktop entries. I still think
this whole system is an unqualified mess, though.

  • Be sure that the game uses my libraries and not the ones provided on
    the user machine (to avoid compatibility issues).

(export LD_LIBRARY_PATH=./mylibs:$LD_LIBRARY_PATH in the game startup
script is enough?)

More or less. Here’s the startup script from Postal 2, using some code
that Sam wrote for Loki to find the right location for “./mylibs”.
(Attached.)

–ryan.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed…
Name: postal2.sh
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20061201/c0175690/attachment.asc

Gabriele Greco wrote:

I’d like to make a binary installer for a game I wrote on linux, this
game obviously use sdl :slight_smile:

I’m just wondering if there are some guides or tutorial about how to
perform the following steps, obviously I’ve googled around a few hours
before posting here, but with almost not useful results…:

  • Obtain a compressed “clickable” installer that runs with almost any
    libc version.

(loki installer + makeself?)

  • Be able to add KDE / Gnome menu entry in the correct way.

(no idea at all about this, I’ve seen that many distributions place the
small xml file used to describe the menu entry in different places, also
the format is slightly different in kde & gnome…, freedesktops may helps?)

  • Be sure that the game uses my libraries and not the ones provided on
    the user machine (to avoid compatibility issues).

(export LD_LIBRARY_PATH=./mylibs:$LD_LIBRARY_PATH in the game startup
script is enough?)

You’re planning to do exactly what I dont want any software to do: go
against the standard installation procedures for my system (Linux debian).

The proper (and yes, painful) way is to make at least a deb for
’stable’; possibly deb’s for testing and for older debians (supporting
the previous stable is now part of debian policy). And you make rpm’s
for umpteen RedHat releases.

If you really want to run in an ‘exotic patch’, dont install.

Greetings,–
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:@Michel_Bardiaux

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/

Michel Bardiaux wrote:

You’re planning to do exactly what I dont want any software to do: go
against the standard installation procedures for my system (Linux debian).

Well I think most not opensource project has no other way to follow…

I like dpkg/apt based systems but I need to make a single installation
procedure that is “idiot proof” and not
limited to a subset of the linux distributions.

I NEED to install my libraries, obviously without interfering with the
system ones, because there are a lot
of incompatibilites.

For instance I need to catch the desktop resolution (see the other
thread very popular today) to support 16:9 resolutions and this is
available only in SDL 1.2.8 or better.

A few of the machines where I tested the game provided only 1.2.6.

I had not only to add LD_LIBRARY_PATH trick but ALSO compile with -rpath
to be sure the libraries used are the ones I ship with the game.

The proper (and yes, painful) way is to make at least a deb for
’stable’; possibly deb’s for testing and for older debians (supporting
the previous stable is now part of debian policy). And you make rpm’s
for umpteen RedHat releases.
This can be done for a rather small application and with enough systems
to keep all those distro.

For big project like this one is (the linux port of
http://www.ankh-game.com ) the installation package is 600mb.

A deb package, a rpm package and a tar (as fallback) would have needed 3
times the disk space… adding nothing but extra complexity because I
cannot depend on system libraries anyway.

I understand your philosophy but if we want (and we want?) Linux to
become a mainstream operative system the installation procedures should
be as simple as possible… And as indipendent from distributions as
possible.

If you really want to run in an ‘exotic patch’, dont install.

What do you mean by “dont” install?

The installation procedure I’ve prepared put all the files in a
directory chosen by the user (root privileges are not needed), this is
an evil installation? It provides also an ./uninstall script to remove
everything.

BTW: Thanks a lot to Ryan and Peter, I’ve produced a very fancy
loki_setup installer (with gtk2, gtk1 and shell support) following your
suggestions :slight_smile:

Bye,
Gabry

PS: Thanks also to Sam and all the other guys behind SDL :slight_smile:

Hello Michel,

Monday, December 4, 2006, 10:18:15 AM, you wrote:

You’re planning to do exactly what I dont want any software to do: go
against the standard installation procedures for my system (Linux debian).

OK, so everyone should run your distro of choice ? It isn’t gonna
happen, hence the need for loki_install.

The proper (and yes, painful) way is to make at least a deb for
’stable’; possibly deb’s for testing and for older debians (supporting
the previous stable is now part of debian policy). And you make rpm’s
for umpteen RedHat releases.

Now try putting that lot onto a CD and expecting the user to know
exactly what to do - and that’s assuming your game fits onto the CD
because you’ve now got 4 copies of it on there.–
Best regards,
Peter mailto:@Peter_Mulholland

I like dpkg/apt based systems but I need to make a single installation
procedure that is “idiot proof” and not
limited to a subset of the linux distributions.

What I think we need something like a Windows Installer equivalent for
Linux. A standard way of installing non-standard games and applications.

I had not only to add LD_LIBRARY_PATH trick but ALSO compile with -rpath
to be sure the libraries used are the ones I ship with the game.

Er, what ? You need to compile the libraries WITHOUT rpath, so that they
will be used no matter where the user decides to install your game.

~ GerryOn Mon, 04 Dec 2006 15:03:49 +0100, Gabriele Greco <gabriele.greco at darts.it> wrote:

Gerry JJ wrote:

What I think we need something like a Windows Installer equivalent for
Linux. A standard way of installing non-standard games and applications.

Remember that Linux (and SDL) run on hardware other than x86, so a single
binary is never going to work.

Colin–
Colin Tuckley | @Colin_Tuckley | PGP/GnuPG Key Id
+44(0)1903 236872 | +44(0)7799 143369 | 0x1B3045CE

There are 10 types of people in the world. Those that know binary, and those
that don’t.

Gerry JJ wrote:

I like dpkg/apt based systems but I need to make a single installation
procedure that is “idiot proof” and not
limited to a subset of the linux distributions.

What I think we need something like a Windows Installer equivalent for
Linux. A standard way of installing non-standard games and applications.

why like M$? i dont have a problem with the way gnu/linux apps
install. (gentoo)

osx apps install nicely, just drag it to the applications folder.> On Mon, 04 Dec 2006 15:03:49 +0100, Gabriele Greco <gabriele.greco at darts.it> wrote:

I had not only to add LD_LIBRARY_PATH trick but ALSO compile with -rpath
to be sure the libraries used are the ones I ship with the game.

Er, what ? You need to compile the libraries WITHOUT rpath, so that they
will be used no matter where the user decides to install your game.

~ Gerry


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

(loki installer + makeself?)

That’s what I use. You’ll probably have to do some tapdancing to make
sure you build with a glibc that works right everywhere, and link with
only what you need, etc. You might do well to just extract Google
Earth’s installer and reuse the binaries from it…a LOT of time was
spent customizing and automating the build of those binaries, including
a gtk+2 installer that falls back to a statically linked gtk1 installer
if there are dependency issues.

Is there any info about this somewhere ? Just grabbing the Google Earth
installer and using that is an option, as you say, but that installer puts
the installed info under ~/.loki. I’d like to use this, but I need that
info elsewhere.

I’m currently using a dedicated build box with Ubuntu 5.10/x86 to keep
glibc dependencies sane. Before that, I was building on Red Hat 6.0 (!),
but the NPTL issues finally forced me to something more modern. You’re

I’m using Gentoo in a chroot with a hacked gcc compiler setting for more
compatible builds, which is very convenient and works perfectly for me.
Stay away from Gentoo’s crossdev, though. (It mostly doesn’t work, even
when it appears to.)

~ GerryOn Fri, 01 Dec 2006 15:48:50 +0100, Ryan C. Gordon wrote:

Hello Colin,

Monday, December 4, 2006, 9:48:11 PM, you wrote:

Remember that Linux (and SDL) run on hardware other than x86, so a single
binary is never going to work.

How many commercial Linux games do you see that work on anything other
than x86?–
Best regards,
Peter mailto:@Peter_Mulholland

why like M$? i dont have a problem with the way gnu/linux apps
install. (gentoo)

WI was just an example, I didn’t say we have to clone it. The important
part is having a standard way of installing non-standard stuff. That way
distros can install things the way they want to (and add to a database for
easy, integrated uninstallation and maybe even configuration and patching),
while developers still have control over what the installer does, install
options, cd keys, and so on.

Also, that you don’t have a problem with the way things work doesn’t
really change the fact that installing binary-only non-distro apps in
Linux is a mess, both for the developer and the end user. The problems
start even before you run the installer. Downloading a makeself file
might show the entire file in the browser window if the server isn’t
configured correctly (since it looks like text), and even when you do get
to save it it’s not saved with execute permissions.

osx apps install nicely, just drag it to the applications folder.

Linux would need an applications folder for that to work…

~ GerryOn Mon, 04 Dec 2006 22:55:03 +0100, matt wrote:

Who said anything about a single binary ? If the installer is standard,
or rather, a standard interface already installed in the distro, the
package doesn’t have to include any executable code for that part. For the
app/game, it could include executables for all supported architectures, and
the installer could choose between them at install time (ala what Loki
Setup does).

Getting it to be standard will be a problem, though.

~ GerryOn Mon, 04 Dec 2006 22:48:11 +0100, Colin Tuckley wrote:

Remember that Linux (and SDL) run on hardware other than x86, so a single
binary is never going to work.

Stuff for GP2X? :slight_smile: Oh I guess maybe you mean “[desktop stuff] other than x86”
:)On Mon, Dec 04, 2006 at 11:02:07PM +0000, Peter Mulholland wrote:

Hello Colin,

Monday, December 4, 2006, 9:48:11 PM, you wrote:

Remember that Linux (and SDL) run on hardware other than x86, so a single
binary is never going to work.

How many commercial Linux games do you see that work on anything other
than x86?


-bill!
bill at newbreedsoftware.com
http://www.newbreedsoftware.com/

Gerry JJ wrote:

why like M$? i dont have a problem with the way gnu/linux apps
install. (gentoo)

WI was just an example, I didn’t say we have to clone it. The important
part is having a standard way of installing non-standard stuff. That way
distros can install things the way they want to (and add to a database for
easy, integrated uninstallation and maybe even configuration and patching),
while developers still have control over what the installer does, install
options, cd keys, and so on.

Also, that you don’t have a problem with the way things work doesn’t
really change the fact that installing binary-only non-distro apps in
Linux is a mess, both for the developer and the end user. The problems
start even before you run the installer. Downloading a makeself file
might show the entire file in the browser window if the server isn’t
configured correctly (since it looks like text), and even when you do get
to save it it’s not saved with execute permissions.

osx apps install nicely, just drag it to the applications folder.

Linux would need an applications folder for that to work…

either make the folder or use /usr/local :)> On Mon, 04 Dec 2006 22:55:03 +0100, matt <@matt4> wrote:

~ Gerry


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

I think he meant “exotic path”? And by “don’t install”, I think he means
"run the app from some subdirectory," e.g., user can run it out of
’/home/username/gamename/’ rather than having to install it to /usr…

-bill!On Mon, Dec 04, 2006 at 03:03:49PM +0100, Gabriele Greco wrote:

If you really want to run in an ‘exotic patch’, dont install.

What do you mean by “dont” install?

Peter Mulholland wrote:

Hello Colin,

Monday, December 4, 2006, 9:48:11 PM, you wrote:

Remember that Linux (and SDL) run on hardware other than x86, so a single
binary is never going to work.

How many commercial Linux games do you see that work on anything other
than x86?

i am not a developer and i am guessing… i might be wrong. i would
guess that there are few, if any, commercial games for any architecture
other than x86 because most that play games have x86. thats probably
the same reason most games are for winblows only, most users run that.
so for a commercial business to make money, they target the largest crowd.

also, i assume there is the M$ FUD in there too preventing some from
publishing games on anything other than windows and x86.

matt

(Man, that paragraph was a mess…). To clarify, the installer could run
install scripts of some kind, providing an interface to do all the things
that installers usually do. The packages could include scripts and icons
and such (in addition to program/data tarballs) in an archive with a
special
magic and/or mimetype to have the distro’s file managers automatically run
these with the installer for this kind of files. Basically a kind of rpm
or
deb, except that this wouldn’t be distro-specific and would have a
graphical
installer with the possibility of showing readmes and eulas, inputting
keys,
selecting options, etc.

~ GerryOn Tue, 05 Dec 2006 00:09:21 +0100, Gerry JJ <@Gerry_Jo_Jellestad> wrote:

Who said anything about a single binary ? If the installer is standard,
or rather, a standard interface already installed in the distro, the
package doesn’t have to include any executable code for that part. For
the
app/game, it could include executables for all supported architectures,
and
the installer could choose between them at install time (ala what Loki
Setup does).

I guess people should manually extract archives, add menu entries as well,
and gain root privileges to be able to create the folder and move things
around, then ? Doesn’t sound very user friendly, does it ? The idea of
application folders requires an entire system that supports it to be of
any use. Somehow I think having a standard install tool would be easier
to pull through.

~ GerryOn Tue, 05 Dec 2006 00:26:51 +0100, matt wrote:

either make the folder or use /usr/local :slight_smile: