Linuxdeployqt packaged under Ubuntu using Qt program

I wrote a point Qt interface program, but found it difficult to transplant to run on other computers not installed Qt environment. Check the information learned, there windowsdeployqt program on the windows, there linuxdeployqt can help us to quickly package on linux.

1. Configure Qt environment

First of all, we first Qt environment is configured, in ~/.bashrcaddition of the:

export PATH=/home/xl/Qt5.9.2/5.9.2/gcc_64/bin:$PATH
export LD_LIBRARY_PATH=/home/xl/Qt5.9.2/5.9.2/gcc_64/lib:$LD_LIBRARY_PATH
export QT_PLUGIN_PATH=/home/xl/Qt5.9.2/5.9.2/gcc_64/plugins:$QT_PLUGIN_PATH
export QML2_IMPORT_PATH=/home/xl/Qt5.9.2/5.9.2/gcc_64/qml:$QML2_IMPORT_PATH

Which /home/xl/Qt5.9.2/5.9.2/directory path to be modified based on Qt installed on your computer.
And then perform sourec ~/.bashrcthe configuration.

2. Compile linuxdeployqt

Project Address: https://github.com/probonopd/linuxdeployqt.git .
Although release compiled packages, but because I am using Ubuntu18, system version is too high, and therefore chose to compile the code.
In order to avoid detection packages compiled runtime versions of our system is too high, the problem does not continue, before we compile, will tools/linuxdeployqt/main.cppin the following code is commented out:

        // openSUSE Leap 15.0 uses glibc 2.26 and is used on OBS
        /*if (strverscmp (glcv, "2.27") >= 0) {    //注释版本检查
            qInfo() << "ERROR: The host system is too new.";
            qInfo() << "Please run on a system with a glibc version no newer than what comes with the oldest";
            qInfo() << "currently still-supported mainstream distribution (xenial), which is glibc 2.23.";
            qInfo() << "This is so that the resulting bundle will work on most still-supported Linux distributions.";
            qInfo() << "For more information, please see";
            qInfo() << "https://github.com/probonopd/linuxdeployqt/issues/340";
            return 1;
        }*/

Then you can make use cmake and compile. Generate good executables are tools/linuxdeployqt/linuxdeployqt.
Finally, for convenience, may be copied to generate the executable program system /usr/local/bin/directory.

3. Packaging

The Qt good copy of the program compiled into a separate folder.
Then execute linuxdeployqt appname.
Will be completed very smoothly under normal circumstances, there will be a current directory Apprun, it can be executed directly.
But sometimes not so well, should be a system still lacks the appropriate library. For example, I encountered the error is:

ERROR: Could not start patchelf.
ERROR: Make sure it is installed on your $PATH.
ERROR: Error reading rpath with patchelf "libQt5Widgets.so" : ""
ERROR: Error reading rpath with patchelf "libQt5Widgets.so" : ""

This error is to show a lack of required pathchelftools can be installed directly resolve:

sudo apt install patchelf

Then appeared the following error:

ERROR: ldd outputLine: "libjasper.so.1 => not found"
ERROR: for binary: "/home/xl/Qt5.9.2/5.9.2/gcc_64/plugins/imageformats/libqjp2.so"
ERROR: Please ensure that all libraries can be found by ldd. Aborting.

This shows that our system is the lack of libqjp2.sothis library. In fact, very strange, local obviously you can already run up, why the lack of the library file. But the solution is simple, what lack of pretend:

sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update
sudo apt install libjasper1 libjasper-dev

After the installation is complete, successfully packaged.

Guess you like

Origin www.cnblogs.com/xl2432/p/11124415.html
Recommended