Creating an installer for Linux
-
I have written a QT application and I want to ship it to users in the company.
The application is managed in GitLab.I now want folks to be able to easily download and install it (Each user might has their own Linux flavor but they are all Linux).
How do I create an installer?
I looked around and found that using GNU autotools you could allow users to simply do:./configure make && make install
but I couldn't figure out how this supposed to work with qt and my *.pro file...
Is there a guide on how to ship software?
-
Simplest way (big initial cost, low cost of maintenance) is to compile your own Qt statically, then link your app to that and put up the binary on your place people can download it on your company's intranet.
There isn't really one thing that will work for all distro's. But you could naturally just look at the many other Qt based apps on places like gitlab which have compile guides. This tends to not be useful as you might not want to force your users to install a compiler and the headers (especially ubuntu is a nightmare when it comes to the amount of packages needed).
-
Simplest way (big initial cost, low cost of maintenance) is to compile your own Qt statically, then link your app to that and put up the binary on your place people can download it on your company's intranet.
There isn't really one thing that will work for all distro's. But you could naturally just look at the many other Qt based apps on places like gitlab which have compile guides. This tends to not be useful as you might not want to force your users to install a compiler and the headers (especially ubuntu is a nightmare when it comes to the amount of packages needed).
-
on Ubuntu, you create a deb file which includes all your code and qt stuff needed. Simply install the deb file on Ubuntu of your client. Use cpack of cmake to do it on Linux. In different Linux distributions, you have to pack your code differently. You may also need to pack your code for different versions of Linux. It can be messy.
-
Hi,
Depending on your end goal (distro aware package or something more generic), you might want to check the linuxdeployqt project.
Static builds have their constraints with regards to both GPL and LGPL which makes them really impractical thus shared build should be prefered.
-
We use a mix of linuxdeploy and linuxdeployqt. Both have their strength and weaknesses. Together these will create an AppImage that can be used on most Linux distributions. It is key that you use an old Linux install with old libraries to support old as well as new Linux distros. We use a CentOS 7 installation to compile. This works on Ubuntu 18 and 20, CentOS/RedHat and OpenSuse/SuSE (not all platforms are well tested). We still have another version compiled on Ubuntu 16, but that does not work anymore on Ubuntu 20. The deploy tools will require to use an older distro or just refuse to work.
Here is the script that we use to create the AppImage:
#!/bin/bash LD_LIBRARY_PATH=../../hdf5-1.10.4/linux64 # additional library paths which are not system-wide export LD_LIBRARY_PATH chmod u+x linuxdeploy*.AppImage export VERSION=1.2.3 echo == Remove old AppDir. == rm -rf AppDir echo == Generate new AppDir. == ./linuxdeploy-x86_64.AppImage --appdir=AppDir --executable=../release/MyApp --desktop-file=MyApp.desktop --icon-file=MyApp.svg echo == Bundle Qt libs and create AppImage. == cd AppDir ../linuxdeployqt-6-x86_64.AppImage MyApp.desktop -qmake=/opt/Qt/5.13.2/gcc_64/bin/qmake -appimage echo == Finish up... == mv MyApp-*-x86_64.AppImage ../MyApp-x86_64.AppImage echo == Done. ==
Having a MyApp.desktop and a MyApp.svg are optional, but help with integration into the start menu.
In addition, we are using the Qt Installer Framework to generate an installer. This will install several files besides the AppImage. Also, it uses
xdg-mime install
to register file extensions andxdg-mime default
to link the file extension with our app. This ensures that you can usexdg-open
on known file types on the console and double click on files in file browsers.The AppImage will have almost all of the necessary runtime libraries (also Qt), even some C/C++ dynamic libraries. There are very few cases where this will still have problems with incompatible dynamic libraries.
PS: There are other approaches besides AppImage, like Flatpak and Snap, which work quite similar. AppImage is the one we picked.
-
Hi!
Like @SimonSchroeder already replied, one option is also to create an Offline installer using Qt Installer Framework. As the payload, you can put the binaries you've built. You can also customize the menu's in the installer and customize the installation procedure using scripting interface.
E.g. this offline installer is created using the Qt Installer Framework: https://download.qt.io/official_releases/qtcreator/8.0/8.0.2/qt-creator-opensource-linux-x86_64-8.0.2.run