I followed all the steps successfully as mention in the Qt documentation:
- Qt for Linux/X11 – Building from Source
- Qt for Linux/X11 –
But I still couldn’t make static Qt application, the executable generated by the above documented steps still needs Qt shared objects on other system.
You need to deploy the application, for this purpose I use the utility
This utility itself collects all the necessary dependencies of your application and you do not have to spend your time on it, or you can automate this process.
You can install from github releases (Windows)
from snapstore (Linux)
sudo snap install cqtdeployer
You can use as follows:
%cqtdeployer% -bin myApp -qmake path/to/Qt/5.x.x/build/bin/qmake.exe -qmlDir path/to/my/qml/files/dir
cqtdeployer -bin myApp -qmake path/to/Qt/5.x.x/build/bin/qmake -qmlDir path/to/my/qml/files/dir
And Run application with sh script (Linux) or exe (Windows)
If you’ll use the version from snap then make sure that you have all the permissions.
If you need use windows version just install application from installer
If you want create a simple installer for you application just add qif option for command of cqtdeployer.
cqtdeployer -bin myApp -qmake path/to/Qt/5.x.x/build/bin/qmake -qmlDir path/to/my/qml/files/dir qif
Details on all the intricacies of cqtdeployer can be found on the official wiki project.
The best way to deploy your application is not necessarily to statically link it for the following reasons:
- LGPL licencing means that your application must now be made public and may not sold (I think) – i.e. since its statically linked and the qt libs are within your executable your executable is now part of the open source.
- Its a massive pain in the arse… I have gone around this loop and know the pain well.
Installing qt-everywhere is also not so great, I just don’t see how you can garantee that the libraries will be the same version as the ones that your program needs.
So what I started to do was create my own script to deploy qt for me. The basic “jist” of this is that you use
ldd to find out which qt libraries you need and copy them into a sub folder (
./lib) within the same folder as your executable to make an install bundle.
Note: on Windows there is a deployqt application which does somthing similar (can’t remember exactly what it is called).
Below I have copied a version of my deploy script. Note that it is quite old now, but I don’t see why it should not work (its not written particularly well), but if not it will give you a start place. Also look out for the plugin’s. In this script I have added code to copy the audio plugin since I was using that. If you are using other plugins then you will need to copy those (they are usually in sub dir’s of the qt libs like …/audio)… I had a todo to try to figure out what plugins are needed from the .pro file but I never got around to that (I would have to pass in the .pro file to this script as well)…
To run, just run this script and pass in the directory that your executable lives in.
# Rememeber start dir
# Determine which dir to deploy in and cd to that dir
if [ -d "$1" ]; then
echo "Deploy dir: $DEPLOY_DIR"
# Run ldd on all files in the directory and create a list of required qt libs
for entry in `ldd $DEPLOY_DIR/* | grep -i qt`; do
if $flag; then
# Only add to the array if it is not already in it
if ! [[ $libsArray =~ $entry ]]; then
echo "adding $entry"
# If we see a "=>" then the next line will be a library
if [ $entry == "=>" ]; then
# Create the required folder structure. Note here we are need the qt audio plugin so we are going to manually copy that as well.
mkdir -p lib
mkdir -p lib/audio
# Now copy these files to the deploy directory
for entry in $libsArray; do
echo "cp -v -f $entry $DEPLOY_DIR/lib"
cp -v -f $entry $DEPLOY_DIR/lib
# Now get the audio lib - this is a plugin that we are using so we need these libs as well.
# Add other plugins here as well.
# TODO: maybe we can read this in from the *.pro file.
cp -v -f `qmake -query QT_INSTALL_BINS`/../plugins/audio/* $DEPLOY_DIR/lib/audio
# Go back to start dir
Once you have all the files you need you should be able to copy the whole lot to another PC and run it. Note: you may have to set the
export LD_LIBRARY_PATH=<path-to-libs> so that the libs can be found… or install the libs into somewhere like
But installing libs is another question/subject!