I wrote some Qt interface programs, but found it difficult to port them to other computers that do not have the Qt environment installed. After checking the information, I learned that there is a windowsdeployqt program on windows and a linuxdeployqt on linux that can help us package quickly. 1. Configure the Qt environment First, we configure the Qt environment and add the following line to ~/.bashrc: 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 The Then execute 2. Compile linuxdeployqt Project address: https://github.com/probonopd/linuxdeployqt.git. Although the compiled package has been released, I am using Ubuntu 18 and the system version is too high, so I still choose to compile the code. In order to avoid the problem that the compiled package detects that our system version is too high and does not continue to execute, we comment out the following code in // openSUSE Leap 15.0 uses glibc 2.26 and is used on OBS /*if (strverscmp (glcv, "2.27") >= 0) { //Comment version check 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 use cmake and make to compile. The generated executable program is Finally, for ease of use, you can copy the generated executable program to the system's 3. Packaging Copy the Qt compiled program to a separate folder. Then execute Generally, it will be completed smoothly. There will be an Apprun in the current directory. Just execute it directly. But sometimes it is not so smooth, probably because the corresponding library is missing in the system. For example, the error I encountered was: 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 indicates that the required pathchelf tool is missing and can be solved by installing it directly: Then the following error occurred:
This shows that the libqjp2.so library is missing in our system. It's actually very strange. The local version can obviously be run, so why is this library file missing? But the solution is very simple, just install what is missing: 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, it is packaged smoothly. Summarize The above is what I introduced to you about how to use linuxdeployqt to package Qt programs in Ubuntu. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: Summary of commonly used time, date and conversion functions in Mysql
>>: Two implementations of front-end routing from vue-router
Table of contents 1. concat() 2. join() 3. push()...
Page turning problem scenario B and C are on the ...
I just started learning about databases recently....
wedge Because the MySQL version installed on the ...
Table of contents Use of Vue mixin Data access in...
Table of contents Vue2 Writing Vue3 plugin versio...
1. Flash plug-in package download address: https:...
Table of contents Preface 1. Null coalescing oper...
The difference between := and = = Only when setti...
Preface This article mainly introduces the releva...
MySQL Query Cache is on by default. To some exten...
Table of contents JavaScript Objects 1. Definitio...
1. Vulnerability Description On May 15, 2019, Mic...
Table of contents 1. Mathematical functions 2. St...
There are many methods on the Internet that, alth...