Linux package software written by QT

reference:

How to package the software we write with Qt-Linux articles-Knowledge

 0. Prepare two scripts

  • ldd.sh script

#!/bin/bash
LibDir=$PWD"/lib"
Target=$1
lib_array=($(ldd $Target | grep -o "/.*" | grep -o "/.*/[^[:space:]]*"))
$(mkdir $LibDir)
for Variable in ${lib_array[@]}
do
    cp "$Variable" $LibDir
done
  • 08-UI-doubleCamera .sh script

Note that the name of the script must be consistent with the program name.

#!/bin/sh
appname=`basename $0 | sed s,\.sh$,,`
dirname=`dirname $0`
tmp="${dirname#?}"
if [ "${dirname%$tmp}" != "/" ]; then
dirname=$PWD/$dirname
fi
LD_LIBRARY_PATH=$dirname
export LD_LIBRARY_PATH
$dirname/$appname "$@"

Add permissions to these two scripts

sudo chmod 777 ldd.sh
sudo chmod 777 hubeihdbtoexcel.sh

1. Add program dependency library

1) Create a new empty folder to store the program and its dynamic library. For example "exe_and_so folder";

 2) Copy the ldd.sh script to the compilation directory, such as "build-08UIdoubleCameraDesktop_Qt_5_14_2_GCC_64bit-Release";

3) Execute "./ldd.sh hubeihdbtoexcel", and a lib folder will be generated in the current directory. It stores the library files that the 08UIdoubleCamera depends on;

4) Copy all the files in the lib folder to the newly created folder "exe_and_so folder" in step 1. At this point, you can delete the generated lib folder and ldd.sh script

2. Add Qt-related dependent libraries

(1) Copy the ldd.sh script to the platforms folder of the Qt5 installation directory;

 (2) Execute "./ldd.sh libqxcb.so", and copy all the files in the generated lib folder to the "exe_and_so folder". Some libraries may be duplicated, just click "Replace". After performing this step, you can delete the generated lib folder and ldd.sh script;

3) Go back to the previous level and copy the entire platforms folder to the "exe_and_so folder". The hierarchical relationship is as shown in the figure below;

4) This step is optional. If the program you write has actions to operate the database, you also need to copy the sqldrivers folder in the directory at the same level as platforms to the "exe_and_so folder";

5) Finally, copy the 08-UI-doubleCamerash.sh script and the 08-UI-doubleCamerash executable file to the "exe_and_so folder". Then compress the entire "exe_and_so folder" and run it after decompression on other machines.

3. Operation verification

Open the terminal at the "exe_and_so folder", execute "./08-UI-doubleCamerash.sh", the program runs normally

 

 

Guess you like

Origin blog.csdn.net/weixin_45824067/article/details/130995404
Recommended