Ubuntu20.04 copy library using linuxdeployqt

introduction

The corresponding dependency library needs to be copied for software release. windows can use the windeployqt provided by qt, and linux also has the corresponding open source tool linuxdeployqt
The general principle is to find the path of the corresponding dependent Library of the executable file through the command line, such as ldd, and copy it to the lib folder under the corresponding path.

Download and compile

Due to the use of a higher version of Ubuntu, the compiled package can not be used normally (such as when the original file is modified after the execution of linuxdeployqt). Finally, choose to compile the source code to solve it, and you can also modify the source code to meet specific needs

1. Download linuxdeployqt


Download address: https://github.com/probonopd/linuxdeployqt/releases
Help documentation: https://github.com/probonopd/linuxdeployqt/blob/master/README.md

2. Compile linuxdeployqt

Unzip and open linuxdeployqt Click pro to compile and generate the corresponding linuxdeploy in the bin folder under the current directory. In order to use it normally, you need to make the following modifications.

2.1 removing version restrictions

Find tools / linuxdeployqt / main CPP, with the following code:

// 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;
}

2.2 remove the restriction of not continuing to execute if the library cannot be found

If the library file cannot be found in the original code, it will be warned and stopped. When I actually use it, I hope to complete the copy that can be found, so I modify the corresponding code. This depends on my personal needs.

Find tools / linuxdeployqt / shared CPP is modified as follows:

if ((outputLine.contains("not found")) && (qtDetectionComplete == 1)){
	LogWarning() << "ldd outputLine:" << outputLine.replace("\t", "");
	//LogError() << "for binary:" << binaryPath;
	//LogError() << "Please ensure that all libraries can be found by ldd. Aborting.";
	//exit(1);
	outputLines.removeAll(outputLine);
}

Prompt which libraries are not found, no longer exit directly, but remove them from outputlines and continue to execute.

use

1. Set environment variables

Modify ~ / bashrc:

vim ~/.bashrc

Add the corresponding path of qt at the end:

export PATH=/opt/Qt5.5.1/5.5/gcc_64/bin:$PATH
export LD_LIBRARY_PATH=/opt/Qt5.5.1/5.5/gcc_64/lib:$LD_LIBRARY_PATH
export QT_PLUGIN_PATH=/opt/Qt5.5.1/5.5/gcc_64/plugins:$QT_PLUGIN_PATH
export QML2_IMPORT_PATH=/opt/Qt5.5.1/5.5/gcc_64/qml:$QML2_IMPORT_PATH

2. Install pathchef tool

sudo apt install patchelf

If you do not install direct copy, you will be prompted as follows:

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.

3. Perform packaging

Put the compiled Linux deployqt under the / usr/local/bin / directory so that it can be called directly from the command line
After placement, execute the following code in the executable Directory:

linuxdeployqt Executable file name -appimage

appimage is the execution parameter. See the description document:

Keywords: Linux Qt Ubuntu

Added by kporter.porter on Thu, 03 Mar 2022 23:34:49 +0200