Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

creating a portable linux binary

A topic by sylvie created Mar 18, 2024 Views: 330 Replies: 7
Viewing posts 1 to 4
(1 edit)

hi there! i stumbled upon the so-called itch.io app book, and it has a chapter on publishing pc linux binaries, but doesnt seem to specify how to bundle the libraries at all.

  • are users meant to locate a build of `lld` then find the required libraries?
  • is the developer responsible for bundling just the right amount of libraries?
  • is there a hidden app manifest for specifying packages for a package manager?
  • is a text file listing the packages sufficient?

my dev environment is linux, a c compiler, and the bare minimum needed for cross compat

would appreciate a detailed answer, and if there is a hidden 5th way that i missed (aside static libraries) id love to know it, thanks

edit: just realised that i misparsed ldd as lld, how embarassing ><

Moderator (3 edits)

There are a few ways to mitigate the library issue on Linux:

  1. Package the libraries with your executable and use a loader shell script that sets LD_LIBRARY_PATH accordingly. This is the method used by Ren'Py.
  2. Speaking of: if your game is in Python, you can use Nuitka or PyInstaller to make a stand-alone directory you can zip up and distribute.
  3. Failing that, use a language that builds all it can statically into the executable. Go, D and Nim are like that. Edit: I think so is Rust.
  4. Actually you can do that with C / C++ too, but it's tricky and some distributions (*cough* Debian *cough*) hate static libraries.
  5. Worst case, use a slightly older Linux to build, and let players know they're going to need SDL2 or whatever installed. They're probably going to have it anyway, and it's no different from telling Windows users to install the latest DirectX.

So, we don't exactly have rules about it because there aren't any, but maybe some of these ideas will help you.

(1 edit)
Package the libraries with your executable and use a loader shell script that sets LD_LIBRARY_PATH accordingly.

are loader scripts actually better than `game.x86_32` `game.x86_64`?

use a language that builds all it can statically into the executable.

as funny as writing `unsafe` `-w -Oz` rust with a custom build system would be, isnt that a little excessive?

Actually you can do that with C / C++ too, but it's tricky and some distributions (*cough* Debian *cough*) hate static libraries.

passing `-Bstatic` to the linker is tricky? or statically compiling the libraries?

Worst case, use a slightly older Linux to build, and let players know they're going to need SDL2 or whatever installed.

any recommendations, with a <2GB installer? i use arch btw

Moderator (1 edit)
are loader scripts actually better than `game.x86_32` `game.x86_64`?

No, but  loader scripts allow you to set LD_LIBRARY_PATH, while a plain executable doesn't.

isnt that a little excessive?

I'm not sure how it works in Rust. I meant in general.

passing `-Bstatic` to the linker is tricky? or statically compiling the libraries?

It's not so simple in C++, and Debian doesn't even package static libraries because its maintainers worship dynamic loading.

any recommendations, with a <2GB installer?

I don't have any concrete suggestions, sorry. SalixOS maybe. It's based on Slackware, a very conservative distribution.

(1 edit)
loader scripts allow you to set LD_LIBRARY_PATH, while a plain executable doesn't.

rpath?

It's not so simple in C++

guess im not learning C++

I see no reason to tell people what packages they need to install. They, as the users of their respective system, ought to know that better than I do.

I also haven’t had many problems with distributing basic Linux executables that load dynamic libraries. By far the worst thing to deal with is glibc’s versioned symbols, but there are ways around it.

are you saying to ignore the rare .1% of the rare .1% that doesnt have sdl2 installed?

(1 edit)

No, I am saying tell them to install SDL2 themselves. I would never ignore the 0.01 percent :).

Your particular example is tricky, because from what I remember, either apt or the Debian repos hate having both 32-bit and 64-bit SDL2 installed at once, so I would make SDL2 an exception.

I switched away from SDL2, though, partly for this reason, and now use either GLFW + OpenGL or just GDI directly.

This topic has been auto-archived and can no longer be posted in because there haven't been any posts in a while.