介绍QT软件的打包方式。两种方式一种是绿色软件,另一种是可安装软件。
QT软件打包 介绍两种打包方式:
绿色软件。即可以直接双击打开的exe执行文件;
安装软件。需要安装,像普通软件一样安装打开。
准备一个可以编译运行通过的QT工程。生成release版本的exe。
提取库文件 Build Qt creator project with release version. By setting:
project -> BuildSettings -> edit build settings: choise Release instead of Debug.
Then build and run the project to create release version executable file(.exe).
Find executable file(.exe) in your path. And copy it to another folder.
Open QT cmd:
Note: if MinGW is 64 bit, make sure you create release with MinGW 64bit.
Input command:(instead demo.exe with name of your .exe)
1 windeployqt E:\Q tProject\E xecutable\d emo.exe -qmldir D:\Q t\Q t5.12.3\5 .12.3\m ingw73_64\q ml E:\Q tProject\E xecutable
You can see library file is added to the path saved your .exe.
After this, copy libgcc_s_dw2-1.dll, libstdc++-6.dll and libwinpthread-1.dll to the path manually. You can find it in the installation path of your QT(such as: D:\Qt\Qt5.8.0\5.8\mingw53_32\bin).
Last step is to pack all file in the path to one exe file.
方法一:Windows绿色软件 Before, make sure you have a qt creator project work successfully.
需要用到Enigma Virtual Box将所需的文件打包成最后的唯一的可执行文件。下载地址 。
具体操作:
管理员权限打开Enigma virtual Box。
Setting,Enter InputFile Name,Enter Output File Name, and Files(Virtual Bpx Files), like this:
For Files(Virtual Box Files) settings, you can drag all file in the path except the .exe file.
Click Run to create MotorDetection_box.exe(Name can be changed to any name you want).
Copy MotorDetection_box.exe to any PC without QT software PC. It works well.
windows可安装软件 工具软件:Inno Setup Compiler。可设置密码等信息。
打开界面,根据界面引导,创建.iss文件,或者打开软件提供的example的iss文件,根据需求修改,例如:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 ; Script generated by the Inno Setup Script Wizard. ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! #define MyAppName "pumpkin-app" #define MyAppVersion "v0.0.1" #define MyAppPublisher "Pumpkin Inc" #define MyAppURL "https://cn.example.com/" #define MyAppExeName "pumpkin-app.exe" #define MyAppAssocName MyAppName + " File" #define MyAppAssocExt ".myp" #define MyAppAssocKey StringChange(MyAppAssocName, " ", "") + MyAppAssocExt [Setup] ; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications. ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) AppId={{1D592000-1D11-4856-9B7F-1E352369000} AppName={#MyAppName} AppVersion={#MyAppVersion} ;AppVerName={#MyAppName} {#MyAppVersion} AppPublisher={#MyAppPublisher} AppPublisherURL={#MyAppURL} AppSupportURL={#MyAppURL} AppUpdatesURL={#MyAppURL} DefaultDirName={autopf}\{ #MyAppName} ChangesAssociations=yes DisableProgramGroupPage=yes ; Uncomment the following line to run in non administrative install mode (install for current user only.) ;PrivilegesRequired=lowest ; OutputDir=D:\p rojects\a pp\d eploy OutputDir=./ OutputBaseFilename={#MyAppName}_setup-{#MyAppVersion} Password=abc Encryption=yes Compression=lzma SolidCompression=yes WizardStyle=modern ; "ArchitecturesAllowed=x64" specifies that Setup cannot run on ; anything but x64. ArchitecturesAllowed=x64 ; "ArchitecturesInstallIn64BitMode=x64" requests that the install be ; done in "64-bit mode" on x64, meaning it should use the native ; 64-bit Program Files directory and the 64-bit view of the registry. ArchitecturesInstallIn64BitMode=x64 [Languages] Name: "english"; MessagesFile: "compiler:Default.isl" Name: "japanese"; MessagesFile: "compiler:Languages\J apanese.isl" [Tasks] Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone [Files] Source: "..\b uild\b in\R elease\{ #MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion Source: "..\b uild\b in\R elease\d 3dcompiler_47.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\b uild\b in\R elease\l ibEGL.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\b uild\b in\R elease\l ibGLESV2.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\b uild\b in\R elease\o pencv_world455.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\b uild\b in\R elease\o pengl32sw.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\b uild\b in\R elease\Q t5Concurrent.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\b uild\b in\R elease\Q t5Core.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\b uild\b in\R elease\Q t5Gui.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\b uild\b in\R elease\Q t5Multimedia.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\b uild\b in\R elease\Q t5MultimediaQuick.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\b uild\b in\R elease\Q t5Network.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\b uild\b in\R elease\Q t5Qml.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\b uild\b in\R elease\Q t5QmlModels.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\b uild\b in\R elease\Q t5QmlWorkerScript.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\b uild\b in\R elease\Q t5Quick.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\b uild\b in\R elease\Q t5QuickControls2.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\b uild\b in\R elease\Q t5QuickTemplates2.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\b uild\b in\R elease\Q t5QuickTest.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\b uild\b in\R elease\Q t5RemoteObjects.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\b uild\b in\R elease\Q t5Svg.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\b uild\b in\R elease\Q t5Test.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\b uild\b in\R elease\Q t5Widgets.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\b uild\b in\R elease\Q t5WinExtras.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\b uild\b in\R elease\v c_redist.x64.exe"; DestDir: "{app}"; Flags: ignoreversion Source: "..\b uild\b in\R elease\t ranslations\* "; DestDir: "{app}\t ranslations"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "..\b uild\b in\R elease\a udio\* "; DestDir: "{app}\a udio"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "..\b uild\b in\R elease\b earer\* "; DestDir: "{app}\b earer"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "..\b uild\b in\R elease\i conengines\* "; DestDir: "{app}\i conengines"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "..\b uild\b in\R elease\i mageformats\* "; DestDir: "{app}\i mageformats"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "..\b uild\b in\R elease\l anguages\* "; DestDir: "{app}\l anguages"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "..\b uild\b in\R elease\m ediaservice\* "; DestDir: "{app}\m ediaservice"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "..\b uild\b in\R elease\p latforms\* "; DestDir: "{app}\p latforms"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "..\b uild\b in\R elease\p laylistformats\* "; DestDir: "{app}\p laylistformats"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "..\b uild\b in\R elease\q mltooling\* "; DestDir: "{app}\q mltooling"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "..\b uild\b in\R elease\Q t\* "; DestDir: "{app}\Q t"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "..\b uild\b in\R elease\Q tGraphicalEffects\* "; DestDir: "{app}\Q tGraphicalEffects"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "..\b uild\b in\R elease\Q tMultimedia\* "; DestDir: "{app}\Q tMultimedia"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "..\b uild\b in\R elease\Q tQml\* "; DestDir: "{app}\Q tQml"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "..\b uild\b in\R elease\Q tQuick\* "; DestDir: "{app}\Q tQuick"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "..\b uild\b in\R elease\Q tQuick.2\* "; DestDir: "{app}\Q tQuick.2"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "..\b uild\b in\R elease\Q tTest\* "; DestDir: "{app}\Q tTest"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "..\b uild\b in\R elease\Q tWinExtras\* "; DestDir: "{app}\Q tWinExtras"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "..\b uild\b in\R elease\s cenegraph\* "; DestDir: "{app}\s cenegraph"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "..\b uild\b in\R elease\s tyles\* "; DestDir: "{app}\s tyles"; Flags: ignoreversion recursesubdirs createallsubdirs ; NOTE: Don't use "Flags: ignoreversion" on any shared system files [Registry] Root: HKA; Subkey: "Software\C lasses\{ #MyAppAssocExt}\O penWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue Root: HKA; Subkey: "Software\C lasses\{ #MyAppAssocKey}"; ValueType: string; ValueName: ""; ValueData: "{#MyAppAssocName}"; Flags: uninsdeletekey Root: HKA; Subkey: "Software\C lasses\{ #MyAppAssocKey}\D efaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{ #MyAppExeName},0" Root: HKA; Subkey: "Software\C lasses\{ #MyAppAssocKey}\s hell\o pen\c ommand"; ValueType: string; ValueName: ""; ValueData: """{app}\{ #MyAppExeName}"" ""%1""" Root: HKA; Subkey: "Software\Classes\Applications\{#MyAppExeName}\SupportedTypes"; ValueType: string; ValueName: ".myp"; ValueData: "" [Icons] Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon [Run] Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
方法一:使用Inno setup软件打开运行iss文件即可;
方法二: 命令行执行,创建脚本,package.sh,输入,执行
1 2 3 4 5 6 set -eSCRIPT_DIR="$( cd "$(dirname "$0 " ) " ; pwd -P) " cd $SCRIPT_DIR /c/'Program Files (x86)' /'Inno Setup 6' /ISCC.exe app.iss
忽略加载目录的指定文件夹或文件 Excludes属性设置忽略路径,忽略文件夹直接写出文件夹名即可(相对于source的路径),忽略文件可以如”logs/*”。
onlyifdoesntexist当存在是不复制文件,可有用于保留用户配置文件。
1 2 Source: "{#BuildDir}\*" ; Excludes: "config,*__pycache__,algo,logs,dumps" ; DestDir: "{app}" ; Flags: ignoreversion recursesubdirs createallsubdirs Source: "{#BuildDir}\config\*" ; CopyMode: onlyifdoesntexist; DestDir: "{app}/config" ; Flags: ignoreversion recursesubdirs createallsubdirs