Qt releases software, windows and linux, and Qt releases error report under linux

windows

1. QT switches to release mode. After compilation, an executable file is generated in the build directory, such as setup.exe, and the file is copied to a separate folder;
2. Find QT in the start menu, and find the cmd command line program in it, similar "Qt 5.7 64-bit for Desktop (MSVC 2013)", click to run;
3. Command line input: cd "path to setup.exe", for example "cd C:\Users\chuwei\Desktop\release", execute;
4 , Then use the windeployqt tool command: windeployqt setup.exe, execute it to copy the dependent library to the current directory.

linux

1. In release mode, QT compiles the executable file. If it is setup, copy it to a newly created folder;
2. Create two new files in this folder: setup.sh and pack.sh;
3. In pack. Add the following content to sh, there are two places that need to be replaced:

#!/bin/sh  
exe="setup" #你需要发布的程序名称
des="/home/chw/setup" #创建文件夹的位置
deplist=$(ldd $exe | awk  '{if (match($3,"/")){ printf("%s "),$3 } }')  
cp $deplist $des

4. Add the following content to setup.sh (no need to modify):

#!/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 "$@"

5. The terminal enters the directory, executes the script ./pack.sh, and the dependent libraries will be automatically copied to the current directory.
ps: When publishing in this way, the dependent plug-in libraries are not copied, such as platforms, sqldrivers, imageformats and other folders in the plugins folder of the qt installation directory. If necessary, copy them manually.

Release error resolution under linux

it could not find or load the Qt platform plugin "xcb" in "" Solution: The
platforms folder is missing, find /opt/Qt5.10.1/5/10/1/gcc_64/plugins/platforms in the QT installation directory, and put platforms Copy the folder to the folder where the executable file is located;
at this time, the platforms folder already contains libqxcb.so, but the probability is still not resolved. Run ldd libqxcb.so, it prompts that libQt5XcbQpa.so.5 is missing, and the file is found in the original Linux system , The file is a link file, find the original file, copy it to the executable program folder, and then create a link, ln -s [original file] [libQt5XcbQpa.so.5];
after that, it may prompt that libQt5DBus.so.5 is missing , And the same method as above to solve;
pit ps: Where can I find libQt5XcbQpa.so.5? /usr/lib/x86_64-linux-gnu and opt/Qt5.10.1/5.10.1/gcc_64/lib have files with the same name. Remember to use the following Qt installation directory, and use the previous system lib directory to do whatever you want wrong.

Prompt that libQt5Core.so.5, libQt5Widgets.so.5, libQt5Gui.so.5 cannot be found. Solution:
These files have been copied to the executable file directory when publishing, but this error will be reported, suggesting that the search path is /usr/lib /x86_64-linux-gnu, not the path where the executable file is located;
reason analysis: the ubuntu system running the release version of the software is installed with other versions of QT, the libQt5Core.so.5 file automatically generated by the system lib directory, and the file we used for development The QT version is inconsistent. Although the file has the same name, it is not required by the software.
Solution: Add the current executable file path to the search dynamic library configuration file in the export mode. See Qt calling dynamic libraries in the linux environment .

Qt program cannot display pictures after release

Excluding factors such as configuration files, resource image paths, etc., try to copy the plugins\imageformats folder in the QT installation directory to the same level directory of the executable file. The imageformats folder contains many image format plugins, such as jpeg, etc., and then in the main. Add the following statement in cpp:

QApplication::addLibraryPath("./plugins");

Recompile and release.
ps: I haven't encountered this kind of problem under Windows, but I have encountered it under Linux. What's more pitted is that it will not report an error when running, and there is no hint of missing libraries.

Qt application icon

Prepare a picture and convert it to ico format online. If it is named mylogo.ico, copy it to the executable file path and add in the main function:

#include <QIcon>
QApplication::setWindowIcon(QIcon("./mylogo.ico"));

This method is common for windows and linux.

Guess you like

Origin blog.csdn.net/weixin_40355471/article/details/111225922