網(wǎng)站浮動窗口如何做江西seo推廣
文章目錄
- 0. 準(zhǔn)備工作
- 1. 使用 `windeployqt` 提取必要的動態(tài)鏈接庫和資源文件
- 1.1 操作步驟
- 1.2 補充
- 2. 使用 `Enigma Virtual Box`將文件夾打包成單個exe
- 2.1 操作步驟
0. 準(zhǔn)備工作
Qt程序打包用到的工具有:
windeployqt
:安裝Qt時自帶Enigma Virtual Box
下載地址 :免費軟件
1. 使用 windeployqt
提取必要的動態(tài)鏈接庫和資源文件
★說明: 本文僅以筆者自己的Qt程序為例進(jìn)行介紹,具體項目請作相應(yīng)的修改。
1.1 操作步驟
-
步驟1. 新建文件夾,命名為
iap
-
步驟2. 拷貝這執(zhí)行文件
從Qt工程中的release文件夾中,將可執(zhí)行文件拷貝到步驟1中新建的文件夾中
-
步驟3. 打開Qt終端
打開對應(yīng)的Qt終端,本例中使用MinGW左編譯器,因此打開Qt6.5.2(MinGW 11.2.0 64-bit)
在終端中進(jìn)入到步驟1中創(chuàng)建好的文件夾 -
運行 windeployqt
指令如下
windeployqt appstm32iap_desktop.exe --qmldir D:\src\qt_ws\stm32iap_desktop\build-stm32iap_desktop-Desktop_Qt_6_5_2_MinGW_64_bit-Release
其中使用 --qmldir
指定了QML-Imports
的搜索路徑,本例中該路徑為工程中release的文件夾。
1.2 補充
補充1:
在其他的博客中僅使用windeployqt appstm32iap_desktop.exe
即可完成。但在實際操作的過程中,打包完的exe無法運行(雙擊無反應(yīng)),加入 --qmldir
后問題解決。再此作為參考。
補充2
windeployqt
具有的功能還有很多,一下列出--hekp-all
的信息。
(base) PS C:\Users\HY\Desktop\iap> windeployqt --help-all
Please specify the binary or folder.Usage: C:\Users\HY\anaconda3\Library\bin\windeployqt.exe [options] [files]
Qt Deploy Tool 5.15.2The simplest way to use windeployqt is to add the bin directory of your Qt
installation (e.g. <QT_DIR\bin>) to the PATH variable and then run:windeployqt <path-to-app-binary>
If ICU, ANGLE, etc. are not in the bin directory, they need to be in the PATH
variable. If your application uses Qt Quick, run:windeployqt --qmldir <path-to-app-qml-files> <path-to-app-binary>Options:-?, -h, --help Displays help on commandline options.--help-all Displays help including Qt specific options.-v, --version Displays version information.--dir <directory> Use directory instead of binary directory.--libdir <path> Copy libraries to path.--plugindir <path> Copy plugins to path.--debug Assume debug binaries.--release Assume release binaries.--pdb Deploy .pdb files (MSVC).--force Force updating files.--dry-run Simulation mode. Behave normally, but do notcopy/update any files.--no-patchqt Do not patch the Qt5Core library.--ignore-library-errors Ignore errors when libraries cannot be found.--no-plugins Skip plugin deployment.--no-libraries Skip library deployment.--qmldir <directory> Scan for QML-imports starting from directory.--qmlimport <directory> Add the given path to the QML module searchlocations.--no-quick-import Skip deployment of Qt Quick imports.--translations <languages> A comma-separated list of languages to deploy(de,fi).--no-translations Skip deployment of translations.--no-system-d3d-compiler Skip deployment of the system D3D compiler.--compiler-runtime Deploy compiler runtime (Desktop only).--no-virtualkeyboard Disable deployment of the Virtual Keyboard.--no-compiler-runtime Do not deploy compiler runtime (Desktop only).--webkit2 Deployment of WebKit2 (web process).--no-webkit2 Skip deployment of WebKit2.--json Print to stdout in JSON format.--angle Force deployment of ANGLE.--no-angle Disable deployment of ANGLE.--no-opengl-sw Do not deploy the software rasterizer library.--list <option> Print only the names of the files copied.Available options:source: absolute path of the source filestarget: absolute path of the target filesrelative: paths of the target files, relativeto the target directorymapping: outputs the source and the relativetarget, suitable for use within anAppx mapping file--verbose <level> Verbose level (0-2).Qt libraries can be added by passing their name (-xml) or removed by passing
the name prepended by --no- (--no-xml). Available libraries:
bluetooth concurrent core declarative designer designercomponents enginio
gamepad gui qthelp multimedia multimediawidgets multimediaquick network nfc
opengl positioning printsupport qml qmltooling quick quickparticles quickwidgets
script scripttools sensors serialport sql svg test webkit webkitwidgets
websockets widgets winextras xml xmlpatterns webenginecore webengine
webenginewidgets 3dcore 3drenderer 3dquick 3dquickrenderer 3dinput 3danimation
3dextras geoservices webchannel texttospeech serialbus webviewArguments:[files] Binaries or directory containing the binary.
補充3
在windeployqt``可以加入--no-(xml)
選項,以減少打包后的大小。本例中加入前為123MB,加入后減為57MB。最終的命令如下。
D:\Qt\6.5.2\mingw_64\bin\windeployqt.exe ^appstm32iap_desktop.exe --qmldir D:\src\qt_ws\stm32iap_desktop\build-stm32iap_desktop-Desktop_Qt_6_5_2_MinGW_64_bit-Release ^
--no-opengl-sw ^
--no-translations ^
--no-system-d3d-compiler ^
--no-3danimation ^
--no-3dcore ^
--no-3dextras ^
--no-3dinput ^
--no-3dlogic ^
--no-3dquick ^
--no-3dquickanimation ^
--no-3dquickextras ^
--no-3dquickinput ^
--no-3dquickrender ^
--no-3dquickscene2d ^
--no-3drender ^
--no-quick3d ^
--no-multimedia ^
--no-svg ^
--no-svgwidgets ^
--no-quick3d ^
--no-quick3dassetimport ^
--no-quick3dassetutils ^
--no-quick3deffects ^
--no-quick3dhelpers ^
--no-quick3dhelpersimpl ^
--no-quick3diblbaker ^
--no-quick3dparticleeffects ^
--no-quick3dparticles ^
--no-quick3dphysics ^
--no-quick3dphysicshelpers ^
--no-quick3druntimerender ^
--no-quick3dutils ^
--no-qmlintegration ^
--no-qmllocalstorage ^
--no-qmlxmllistmodel ^
--no-virtualkeyboard ^
--no-sql ^
--no-statemachine ^
--no-statemachineqml ^
--no-concurrent ^
--no-quicktimeline ^
--no-quicktest
可將上面指令保存到.bat
的文件中,在Qt終端中運行。
2. 使用 Enigma Virtual Box
將文件夾打包成單個exe
上述操作后,程序雖然被提取出工程文件夾,但依然需要進(jìn)入文件夾,雙擊可執(zhí)行程序運行。該部分將上述創(chuàng)建的文件夾整體打包成可執(zhí)行的exe文件。步驟如下。
2.1 操作步驟
- 步驟1:安裝
Enigma Virtual Box
,從官方網(wǎng)站進(jìn)行下載,并安裝(下載地址 )。 - 步驟2:選擇輸入的exe文件,即上述新建文件夾中的可執(zhí)行文件
- 步驟3:選擇輸出的文件名。默認(rèn)狀態(tài)下與輸入exe文件同目錄,可以進(jìn)行修改
- 步驟4:添加程序運行的配套文件。
在步驟3中選擇上述新建文件夾,點擊確定和OK完成添加。
最終配置結(jié)果如下,點擊Process
即可生成。
結(jié)果展示