I recently went through the process of creating a Unity game for Linux and wanted to package it into a .deb
file so I could later upload it to the Ubuntu Software Center.
When I ran the following command:
debuild -d -us -uc
I hit a brick wall.
Instead of a nice shiny .deb
file, I was greeted with a long list of dependency errors. Let’s walk through what happened, why it happened, and how I fixed it.
My Original debian/rules
File
Here’s the file I started with:
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
%:
dh $@
Note: In my original pasted version, the tab before dh $@
was replaced by spaces. Makefiles require real tabs, not spaces. That’s a subtle but important thing.
The Error I Got
The output from debuild
was littered with lines like this:
dpkg-shlibdeps: error: couldn't find library librt.so.1 needed by ...
dpkg-shlibdeps: error: couldn't find library libdl.so.2 needed by ...
dpkg-shlibdeps: error: cannot continue due to the errors listed above
Why This Happen
Here’s the problem:
dpkg-shlibdeps
scans my binaries to figure out which shared libraries (.so
files) they need. My Unity build shipped with 64-bit .so
files, but my packaging environment was either:
- Running a 32-bit architecture build.
- Missing the 64-bit libraries entirely.
- Not told where to find libraries in non-standard paths.
This meant the system simply couldn’t locate common libraries like libc.so.6
, libm.so.6
, libpthread.so.0
, and GTK dependencies.
How I Fix It
I found three ways to solve this problem depending on the environment:
Install Missing Multi Arch Libraries
If you’re on a 32-bit base but building a 64-bit game, you need to enable amd64
and install the right libraries:
sudo dpkg --add-architecture amd64
sudo apt update
sudo apt install libc6:amd64 libgtk2.0-0:amd64 libglib2.0-0:amd64 libgdk-pixbuf2.0-0:amd64
Tell dpkg to Ignore Bundled Unity Libraries
If you know Unity’s .so
files don’t need to be linked against system libs for packaging, you can skip them:
override_dh_shlibdeps:
dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info
Or exclude a specific directory:
override_dh_shlibdeps:
dh_shlibdeps -Xraining_coins_Data
Use the Right Architecture
Make sure your debian/control
explicitly sets the architecture:
Architecture: amd64
Improve debian/rules
for Unity Games
Here’s the upgraded version I now use:
#!/usr/bin/make -f
# Enable verbose mode
export DH_VERBOSE=1
# Set architecture explicitly
DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
%:
dh $@
# Custom install step to ensure Unity files are in the right place
override_dh_auto_install:
mkdir -p debian/rainingcoins/opt/rainingcoins
cp -r build/linux/$(DEB_HOST_ARCH)/* debian/rainingcoins/opt/rainingcoins/
# Fix shared library dependency issues by ignoring bundled Unity libs
override_dh_shlibdeps:
dh_shlibdeps -Xraining_coins_Data
# Include documentation automatically
override_dh_installdocs:
dh_installdocs README.md CHANGELOG.md
What This Adds
- Architecture detection so I don’t hardcode
amd64
everywhere. - Correct install path for Unity output files.
- Skips
shlibdeps
errors for Unity’s private.so
files. - Installs docs automatically, which makes for a cleaner package.
Final Thought
Packaging isn’t just about zipping files together it’s about making sure your environment matches the binaries you’re trying to ship. Unity builds for Linux are usually 64-bit, so building them in a 32-bit or unprepared environment will almost always cause dpkg-shlibdeps
to fail. With the fixes above, I was able to generate a .deb
package without dependency errors and successfully install my game. Now I can focus on the fun part getting it in front of players.