Adding libraries to a new Linux computer for any application written in Qt 5.15

Screenshot of my application
I wrote an application (launcher creator like Linux Mint's) in Qt 5.15.2 version. I completed developing and everything was ok.
Then, I wanted to check it if working at any computer without Qt installed.

For this, I checked the dependency of the application file on my computer (Ubuntu 20.04 LTS) with ldd command like below

ldd LauncherCreator

result:

    linux-vdso.so.1 (0x00007ffe2c7a9000)
    libQt5Widgets.so.5 => /opt/Qt/5.15.2/gcc_64/lib/libQt5Widgets.so.5 (0x00007f2d1eae1000)
    libQt5Gui.so.5 => /opt/Qt/5.15.2/gcc_64/lib/libQt5Gui.so.5 (0x00007f2d1e1b0000)
    libQt5Core.so.5 => /opt/Qt/5.15.2/gcc_64/lib/libQt5Core.so.5 (0x00007f2d1d9ba000)
    libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f2d1d7c6000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f2d1d7ab000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2d1d5b9000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f2d1d594000)
    libGL.so.1 => /lib/x86_64-linux-gnu/libGL.so.1 (0x00007f2d1d50c000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f2d1d3bd000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f2d1d3a1000)
    libicui18n.so.56 => /opt/Qt/5.15.2/gcc_64/lib/libicui18n.so.56 (0x00007f2d1cf08000)
    libicuuc.so.56 => /opt/Qt/5.15.2/gcc_64/lib/libicuuc.so.56 (0x00007f2d1cb50000)
    libicudata.so.56 => /opt/Qt/5.15.2/gcc_64/lib/libicudata.so.56 (0x00007f2d1b16b000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f2d1b165000)
    libgthread-2.0.so.0 => /lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f2d1b160000)
    libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f2d1b037000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f2d1f35c000)
    libGLdispatch.so.0 => /lib/x86_64-linux-gnu/libGLdispatch.so.0 (0x00007f2d1af7f000)
    libGLX.so.0 => /lib/x86_64-linux-gnu/libGLX.so.0 (0x00007f2d1af49000)
    libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f2d1aed6000)
    libX11.so.6 => /lib/x86_64-linux-gnu/libX11.so.6 (0x00007f2d1ad99000)
    libxcb.so.1 => /lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f2d1ad6f000)
    libXau.so.6 => /lib/x86_64-linux-gnu/libXau.so.6 (0x00007f2d1ad69000)
    libXdmcp.so.6 => /lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f2d1ad5f000)
    libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f2d1ad45000)

To solve this problem, I only copied libraries that appeared above related to Qt and pasted to a new folder called lib.
I wrote an installer script for other computers to download necessary libraries and install properly. (Maybe the real problem is here. Pay attention to STEP 4)

#!/bin/bash

sudo echo -----------------------------

# install libGL
echo -----------------------------
echo 'STEP 1: install libGL'
echo
sudo apt install libgl1-mesa-dev -y

# create application folder
echo -----------------------------
echo 'STEP 2: create application folder'
echo
cd /opt/
sudo rm -r LauncherCreator
sudo mkdir LauncherCreator
cd LauncherCreator
sudo mkdir lib

# go into the temporary folder
cd ~/Desktop/temp_LauncherCreator

# change mode to executable
chmod +x ~/Desktop/temp_LauncherCreator/BUILD/LauncherCreator
chmod +x ~/Desktop/temp_LauncherCreator/uninstall_LauncherCreator.sh

# copy files to application folder
echo -----------------------------
echo 'STEP 3: copy files application folder'
echo
sudo cp ~/Desktop/temp_LauncherCreator/BUILD/LauncherCreator         /opt/LauncherCreator
sudo cp ~/Desktop/temp_LauncherCreator/LauncherCreator/rocket.ico    /opt/LauncherCreator
sudo cp ~/Desktop/temp_LauncherCreator/currentVersion                /opt/LauncherCreator
sudo cp ~/Desktop/temp_LauncherCreator/uninstall_LauncherCreator.sh  /opt/LauncherCreator
sudo cp ~/Desktop/temp_LauncherCreator/lib/*                         /opt/LauncherCreator/lib/

# create links
echo -----------------------------
echo 'STEP 4: create links for lib'
echo
cd /opt/LauncherCreator/lib
sudo ln -s libicudata.so.56.1      libicudata.so.56
sudo ln -s libicudata.so.56        libicudata.so
sudo ln -s libicui18n.so.56.1      libicui18n.so.56
sudo ln -s libicui18n.so.56        libicui18n.so
sudo ln -s libicuuc.so.56.1        libicuuc.so.56
sudo ln -s libicuuc.so.56          libicuuc.so
sudo ln -s libQt5Core.so.5.15.2    libQt5Core.so.5.15
sudo ln -s libQt5Core.so.5.15      libQt5Core.so.5
sudo ln -s libQt5Core.so.5         libQt5Core.so
sudo ln -s libQt5Gui.so.5.15.2     libQt5Gui.so.5.15
sudo ln -s libQt5Gui.so.5.15       libQt5Gui.so.5
sudo ln -s libQt5Gui.so.5          libQt5Gui.so
sudo ln -s libQt5Widgets.so.5.15.2 libQt5Widgets.so.5.15
sudo ln -s libQt5Widgets.so.5.15   libQt5Widgets.so.5
sudo ln -s libQt5Widgets.so.5      libQt5Widgets.so

# copy launcher to /usr/share/applications/
echo -----------------------------
echo 'STEP 5: copy launcher'
echo
chmod +x ~/Desktop/temp_LauncherCreator/Launcher_Generator.desktop
sudo  cp ~/Desktop/temp_LauncherCreator/Launcher_Generator.desktop /usr/share/applications/

# remove temporary folder
echo -----------------------------
echo 'STEP 6: remove temporary folder'
echo
sudo rm -r ~/Desktop/temp_LauncherCreator

# update applications
echo -----------------------------
echo 'STEP 7: update applications'
echo
sudo apt install update -y

####
echo
echo 'OK'
echo
echo '-----------------------------'
echo 'Bunyamin TAMAR'
echo 'linkedin.com/in/bunyamintamar'
echo 'December 2021'
echo '-----------------------------'
echo
sleep 5
/opt/LauncherCreator/LauncherCreator
exit

This is my pro file:

QT        += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG    += c++11
SOURCES   += $$files("*.cpp", false)
HEADERS   += $$files("*.h",   false)
FORMS     += $$files("*.ui",  false)
RESOURCES += $$files("*.qrc", false)

This application works perfectly in my computer with Qt 5.15. But, at the other computer (Ubuntu 20.04 LTS), it doesn't work.

How can I solve this problem?

You can also see this files on my GitHub account. If I solve this problem, will share this application on my blog.
(only the name of the application there is different)


Developing applications for mass distribution using binary distributed Qt is bad idea. Random symlink creation is bad idea too. You have to choose your target platform and use its Qt version. For example 20.04 LTS has 5.12. Or even lower to support 18.04 LTS. Your application looks great, but it will work normally with older Qt version. Please do not create problems for the users of your great application. Next step to do this correctly is to create PPA to compile deb-packages for currently supported Ubuntu releases.

Also please do not get me wrong but we already have two mature applications for the mentioned purpose - see:

  • mate-desktop-item-edit from mate-panel package:

    mate-desktop-item-edit

  • exo-desktop-item-edit from exo-utils package:

    exo-desktop-item-edit

They are good replacement for previously available gnome-desktop-item-edit application from gnome-panel package (see this Q&A for details about its history).