qt程序打包發(fā)布
目標(biāo): 我想安裝自己開發(fā)的程序
1.打包依賴庫
a.使用qtcreator編譯生成程序demo.exe碍沐,這是一個(gè)release版的
b.在程序demo.exe目錄打開cmd
c.輸入命令
C:\Qt\Qt5.10.1\5.10.1\mingw53_32\bin\windeployqt.exe demo.exe --qmldir C:\Qt\Qt5.10.1\5.10.1\mingw53_32\qml
d.這樣demo.exe運(yùn)行依賴的庫都會(huì)自動(dòng)拷貝到同目錄
2.Qt Installer Framework
a.去官網(wǎng)下載工具 http://download.qt.io/development_releases/installer-framework/3.0.1/installer-framework-build-stripped-3.0.1-win-x86.7z
b.解壓到C:\Qt\ifw-pkg,examples目錄是例子
c.把之前得到的demo.exe同目錄下所有文件拷貝到
C:\Qt\ifw-pkg\examples\tutorial\packages\com.vendor.product\data,
data目錄存放的是將來安裝程序時(shí)候要釋放安裝的程序數(shù)據(jù)
d.在C:\Qt\ifw-pkg\examples\tutorial目錄打開cmd
e.輸入命令转培,創(chuàng)建離線安裝包
C:\Qt\ifw-pkg\bin\binarycreator.exe --offline-only -t C:\Qt\ifw-pkg\bin\installerbase.exe -c config\config.xml -p packages demo.exe
f.這樣就在tutorial目錄生成安裝包demo.exe
3.測(cè)試安裝包
a.運(yùn)行demo.exe
b.像一般軟件那樣下一步進(jìn)行安裝
c.安裝完成后在C:\Users\chen\InstallationDirectory目錄會(huì)看到安裝結(jié)果
d.InstallationDirectory目錄的maintenancetool.exe是維護(hù)工具咽弦,demo.exe就是我們的程序
詳情參考官網(wǎng) https://doc.qt.io/qtinstallerframework/index.html
4.希望安裝程序后在開始菜單添加快捷方式
a.修改tutorial\packages\com.vendor.product\meta\installscript.qs文件
Component.prototype.createOperations = function()
{
try {
// call the base create operations function
component.createOperations();
if (systemInfo.productType === "windows") {
component.addOperation("CreateShortcut", "@TargetDir@/demo.exe", "@StartMenuDir@/Love.lnk",
"workingDirectory=@TargetDir@", "iconPath=@TargetDir@/demo.exe",
"iconId=0", "description=Open Love file");
}
} catch (e) {
console.log(e);
}
}
b.重新生成安裝包蛔垢,安裝