Quick answer: The dynamic loader could not find a shared library your binary lists as needed, either because the player’s distro does not ship that version or because you shipped it and the loader never searches the game folder. Run ldd ./MyGame.x86_64 | grep "not found", put the missing libraries in a lib folder beside the binary, and link with -Wl,-rpath,'$ORIGIN/lib' so they are found wherever the game is installed.

On Linux this failure is usually invisible. The player presses Play, the button flips back, and nothing appears, because the one line that explains it went to a terminal nobody was looking at. The line itself is precise: it names the exact file the loader wanted. What it does not say is why your machine had that file and theirs did not. This guide covers how the loader searches, three commands that show what your build depends on, the library versions that differ between distros, how to bundle libraries so the game folder is self-contained, and what Steam’s runtimes do and do not give you.

The exact error

./MyGame.x86_64: error while loading shared libraries: libfoo.so.1: cannot open shared object file: No such file or directory

The library name is the part that changes. Real examples:

./MyGame.x86_64: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory
./MyGame.x86_64: error while loading shared libraries: libsteam_api.so: cannot open shared object file: No such file or directory
./MyGame.x86_64: error while loading shared libraries: libSDL2-2.0.so.0: wrong ELF class: ELFCLASS32

The message comes from the dynamic loader (ld.so), on standard error, before main runs, and the process exits with status 127. Each ELF binary carries a list of NEEDED library names. The loader resolves every one of them, and the first it cannot find ends the launch. “wrong ELF class” means it found a file with that name built for the other word size: a 32-bit library offered to a 64-bit game, or the reverse.

A library opened later with dlopen, which is how engines load plug-ins, produces the same sentence without the prefix, inside the engine’s log instead of at startup.

Why players see nothing

A game started from Steam or a desktop icon has no terminal, so standard error is discarded. To see the message, the player has to run the binary from a terminal in the game folder (in Steam: right-click the game, Manage > Browse local files, then open a terminal there), or redirect the output with a Steam launch option:

%command% > ~/mygame-output.log 2>&1

Without one of those, the report you get is “it does not start”. Getting logs from a Steam Deck covers the same steps for a player with no keyboard.

For each needed name, the loader tries these places in order (the ld.so manual page is the reference):

  1. DT_RPATH directories recorded in the binary, only if it has no DT_RUNPATH. Deprecated.
  2. Directories in the LD_LIBRARY_PATH environment variable.
  3. DT_RUNPATH directories recorded in the object that needs the library.
  4. The cache /etc/ld.so.cache, which ldconfig builds from the system library directories.
  5. The default directories, /lib and /usr/lib and their 64-bit variants.

Two facts in that list cause most launch failures. The folder the executable lives in is not searched, and neither is the current directory. Developers coming from Windows expect a library next to the binary to be found, and on Linux it is not, unless a run path says so. And DT_RUNPATH applies only to the direct dependencies of the object that carries it: a run path on your executable does not help a bundled library find its dependencies.

How to find what is missing

Copy the build to a machine or container that is not your development system and run:

ldd ./MyGame.x86_64 | grep "not found"
	libfoo.so.1 => not found

ldd resolves the whole tree, so it also reports a dependency of a dependency. To see which of your bundled files is the one with the unresolved reference:

find . -name '*.so*' -type f -exec sh -c 'ldd "$1" 2>/dev/null | grep -q "not found" && echo "$1"' _ {} \;

Then look at what the binary asks for and where it was told to look:

readelf -d ./MyGame.x86_64 | grep -E 'NEEDED|RPATH|RUNPATH'
 0x0000000000000001 (NEEDED)             Shared library: [libfoo.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/lib]

No RUNPATH line means the loader will only use system locations. A RUNPATH such as /home/ci/build/third_party/lib means the build only works on the machine that made it. For the full story of one launch, ask the loader to narrate:

LD_DEBUG=libs ./MyGame.x86_64 2>&1 | less

It prints every find library= request, the search path used and its origin (“RUNPATH from file”, “system search path”), and each file it tried.

What causes it

  1. You linked against a library that only your distro has in that version. A library’s file name includes its ABI version, and distros move at different speeds. OpenSSL is libssl.so.1.1 on Ubuntu 20.04 and Debian 11 but only libssl.so.3 on Ubuntu 22.04 and Debian 12 and later. libcurl-gnutls.so.4 is a Debian and Ubuntu flavour that other distros do not install by default. libpng12.so.0 is gone from current distros, libidn.so.11 became libidn.so.12, and ICU changes its file name with every release.
  2. You shipped the library but not a way to find it. libsteam_api.so or your own .so sits next to the binary, there is no run path, and it only ever worked because of an LD_LIBRARY_PATH in your shell or a launch script the player bypassed.
  3. The run path points at your build machine. The linker recorded an absolute path from your CI workspace.
  4. A bundled library has its own dependency. The executable finds lib/libfoo.so.1 through its run path, but libfoo needs libbar.so.1 and has no run path of its own.
  5. A 32-bit and 64-bit mix. A 32-bit plug-in in a 64-bit build gives “wrong ELF class”. A fully 32-bit game on a distro with no 32-bit libraries fails earlier, with the shell reporting that the binary itself was not found, because its loader is missing.
  6. It worked inside Steam and fails outside, or the reverse. Steam starts games with one of its runtimes, which supplies a set of libraries. The same binary run from a terminal, from itch.io or from another launcher gets none of them.
  7. The player cannot install packages. SteamOS on the Steam Deck has a read-only system image, and Steam installed as a Flatpak sees the Flatpak runtime’s libraries, not the host’s. “Install libfoo with your package manager” is not an answer for either.

Fix 1: bundle the libraries and set RUNPATH to $ORIGIN

$ORIGIN is expanded by the loader to the directory containing the object being loaded, which makes a run path relative to wherever the game is installed. Copy what you need into a folder (cp -L follows symlinks so you get the real file under the name the loader asks for) and link with a run path:

mkdir -p lib
cp -L /usr/lib/x86_64-linux-gnu/libfoo.so.1 lib/
g++ -o MyGame.x86_64 *.o -lfoo -Wl,-rpath,'$ORIGIN/lib'

Keep the single quotes, or the shell expands $ORIGIN to nothing. In CMake:

set_target_properties(MyGame PROPERTIES
  BUILD_WITH_INSTALL_RPATH TRUE
  INSTALL_RPATH "$ORIGIN/lib")

For binaries you cannot relink, including third-party libraries with their own dependencies, set it after the fact:

patchelf --set-rpath '$ORIGIN/lib' MyGame.x86_64
for f in lib/*.so*; do patchelf --set-rpath '$ORIGIN' "$f"; done

patchelf --set-rpath writes DT_RUNPATH. The loop gives every bundled library a run path to its own folder, which fixes cause 4.

Do not bundle everything ldd lists. Leave out the C library family (libc.so.6, libm.so.6, ld-linux), which must come from the system and has its own failure mode covered in version GLIBC not found, and the graphics driver stack (libGL, libEGL, libvulkan), which must match the player’s driver. Do not bundle libstdc++.so.6 either: an older copy than the system’s can stop the system’s graphics driver from loading. Link it statically instead.

Fix 2: static linking, and a launch script as a fallback

Small dependencies are simplest linked statically: zlib, libpng, your own libraries. For C++ add -static-libstdc++ -static-libgcc. Check licences first: LGPL libraries are easier to comply with as separate .so files a player can replace. Avoid the system OpenSSL entirely. Either bundle the TLS library you built against, or use an HTTP stack that carries its own.

When you cannot change run paths, a script can set the search path. It works, with two costs: the variable is inherited by every child process, and a player or launcher that starts the binary directly skips it.

#!/bin/sh
here="$(dirname "$(readlink -f "$0")")"
export LD_LIBRARY_PATH="$here/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
exec "$here/MyGame.x86_64" "$@"

Fix 3: target a Steam Linux Runtime on purpose

On Steam, a native Linux game runs inside a runtime whether you chose one or not, and the runtime decides which libraries exist:

Name in SteamLibrary setStatus
Steam Linux Runtime 1.0 (scout)Ubuntu 12.04-era libraries, inside a Debian 10 based containerStill the default when you publish a native Linux game
Steam Linux Runtime 3.0 (sniper)Debian 11 based containerOlder container runtime
Steam Linux Runtime 4.0Debian 13 based containerWhat Valve recommends for new native Linux games

Per Valve’s steam-runtime README, you target one by compiling inside that runtime’s SDK container image, setting up a launch option that supports Linux, and choosing the runtime under Installation > Linux Runtime in the Steamworks partner site. Building in the SDK guarantees you only link against libraries the runtime contains. Anything outside that set you still bundle, and builds you sell elsewhere get no runtime at all, so Fix 1 remains the baseline.

Engine notes

What to tell players

  1. Start the game from a terminal in its folder (./MyGame.x86_64) and send the complete line it prints. The library name in it is what the developer needs.
  2. Verify the game files in Steam, in case a bundled library was removed.
  3. If the missing library is an ordinary package on your distro, installing it is a reasonable workaround. On Steam Deck or with the Flatpak version of Steam, skip this step.
  4. Do not symlink a different version to the missing name, for example libssl.so.3 to libssl.so.1.1. The versions are not compatible and the game will crash later instead.
  5. If the game also has a Windows build, forcing Proton under Properties > Compatibility lets you play while the Linux build is fixed. If that fails too, see a game not launching on Steam Deck.

How to confirm the build is self-contained

Run the dependency check in clean containers of the distros you support. Nothing has to start, so no display is needed:

for img in ubuntu:22.04 ubuntu:24.04 debian:12 fedora:latest archlinux:latest; do
  echo "== $img"
  docker run --rm -v "$PWD:/game:ro" "$img" sh -c 'ldd /game/MyGame.x86_64 | grep "not found"'
done

Base images have no graphics or audio stack, so lines for libGL, libX11 and similar are expected there. Any other line is a library you must bundle or link statically. Then move the build folder to a different path on a real desktop, unset LD_LIBRARY_PATH, and start the binary directly, not through your script and not through Steam. If it starts from there, the run paths are doing the work.

What Bugnet sees of this

When the loader stops the process, no SDK inside it can report anything, and Bugnet is no exception. Two things still reach you. A library that fails later through dlopen is an ordinary error inside a running game: the Unity SDK files the DllNotFoundException with its stack trace, and the Godot SDK picks the load error out of the engine log when file logging is enabled, each with the OS version, game version and recent log lines, stacked into one report with an occurrence count. For the startup failure, a known-issue entry on the project’s public tracker, titled with the error text and containing the terminal instructions above, turns “it does not start” into a library name you can act on.

Frequently asked questions

What does “error while loading shared libraries: cannot open shared object file” mean?

The Linux dynamic loader could not find a shared library that the program lists as required. Either the library is not installed on the system in that exact version, or it was shipped with the game in a folder the loader does not search.

How do I find which shared libraries are missing?

Run ldd on the binary and filter for not found, for example ldd ./MyGame.x86_64 piped through grep “not found”. It lists every required library that cannot be resolved on that machine, including dependencies of the libraries you bundled.

Why does Linux not find a library that is in the same folder as the game?

The loader does not search the executable’s folder or the current directory. It only searches run paths recorded in the binary, LD_LIBRARY_PATH and the system library locations. Linking with an rpath of $ORIGIN makes it search relative to the binary.

What is the difference between RPATH and RUNPATH?

Both are search directories stored in a binary. RPATH is the older form, searched before LD_LIBRARY_PATH and applied to the whole dependency tree. RUNPATH is searched after LD_LIBRARY_PATH and applies only to the direct dependencies of the object that carries it. Current linkers usually write RUNPATH.

Does the Steam Linux Runtime mean I do not need to bundle libraries?

It means the libraries in that runtime are present for Steam players. Libraries outside the runtime’s set still have to be bundled, and copies of the game sold outside Steam run without any runtime, so a self-contained build is still the safe default.

Linux never looks next to the executable unless a run path tells it to. Set RUNPATH to $ORIGIN on the binary and on every library you bundle.