How to Prepare Qt Apps for Release on Linux

How to Prepare Qt Apps for Release on Linux

This is the Linux portion of my complete guide to Qt desktop releases found here(coming soon).

If you read the macOS and Windows parts of my guide you may notice that Linux is comparatively simpler. This is because the Linux ecosystem has not decided on a standard code-signing authority, so apps on Linux are generally unsigned.

I will be using Ubuntu 16.04 LTS for this tutorial as it’s the oldest LTS supported by Qt currently. You should generally build with the oldest possible LTS version to ensure compatibility. Newer OS versions are not guaranteed to produce backwards-compatible binaries.

Step 1 – Release

Start by building a release version of your application. This will spit out a Linux binary file somewhere in your project, depending on how you have set it up. By default, shadow-build will place the binary file in a folder next to your main project folder.

The name of my project is quicktest. The shadow-build folder selected contains my generated binary.

Inside the shadow-build folder should be an binary with your application’s name.

quicktest is the name of our application.

Notice how the binary is tiny, this is because it doesn’t yet contain its dependencies and if we were to distribute it as-is to a client that does not have Qt installed, it would fail to run.

Step 2 – Installing linuxdeployqt

This step is a bit different to the other OSes because Qt does not ship a “linuxdeployqt” tool. We instead use a community-created tool called, interestingly, “linuxdeployqt”.

First we’ll go to the github repo and download the latest .AppImage . After it’s downloaded install it to your /usr/local/bin for easier future usage:

chmod +X linuxdeployqt-7-x86_64.AppImage
sudo cp linuxdeployqt-7-x86_64.AppImage /usr/local/bin/linuxdeployqt

Step 3 – Deploying

Before we run linuxdeployqt we need to do some housekeeping. Let’s remove all the files we won’t need, so everything except the “quicktest” binary. Next, create a file called “default.desktop”, containing the app’s configuration:

[Desktop Entry]
Type=Application
Name=quicktest
Exec=AppRun %F
Icon=default
Comment=Edit this comment
Terminal=true
Categories=Utility;

I set up some defaults that you will probably want to change for yourself, but this will work for our little test.

You should also add a “default.png” image that will serve as your app’s icon.

What your release folder should look like at this point

To run linuxdeployqt we’ll need Qt in our path, so let’s temporarily add it as to not tamper with the system Qt. I will also include a qmldir because I am using QML for this demonstration.

PATH="$HOME/Qt/5.12.10/gcc_64/bin:$PATH"
linuxdeployqt quicktest -appimage -qmldir=../quicktest

If it all went well you should now have a .AppImage file ready to distribute!

Note: I recommend distributing the .AppImage in a .tar.gz compressed format, so your users do not have to fiddle with permissions when running it. To tar the AppImage:

tar -czvf quicktest.tar.gz quicktest-x86_64.AppImage