therecipe/qt跨平台编译
你只需使用M交叉环境(MXE)。它消除了整个过程中的痛苦:
- 得到它:
$ git clone https://github.com/mxe/mxe.git
- 安装构建依赖关系
- 为Windows构建Qt及其依赖关系和跨构建工具; 这将需要大约一个小时的快速机器与体面的互联网接入; 下载大约500MB:
$ cd mxe && make qt
- 转到您的应用程序目录并将交叉构建工具添加到PATH环境变量中:
$ export PATH=<mxe root>/usr/bin:$PATH
- 运行Qt Makefile生成器工具,然后构建:
$ <mxe root>/usr/i686-pc-mingw32/qt/bin/qmake && make
- 您应该在./release目录中找到二进制文件:
$ wine release/foo.exe
------------
% qtdeploy build windows inwhtl
ERRO[0006] failed to run command _func=RunCmd cmd="/usr/lib/mxe/usr/i686-w64-mingw32.shared/qt5/bin/qmake -query QT_INSTALL_PREFIX" dir= env= error="fork/exec /usr/lib/mxe/usr/i686-w64-mingw32.shared/qt5/bin/qmake: no such file or directory" name="query install prefix path for windows on darwin"
交叉编译环境MXE
mac to windows , ok
---------------------------------
docker pull therecipe/qt:windows_32_shared
qtdeploy -docker build windows_32_shared
教程,GOPATH环境变量不知道怎么配,没有找到教程。
https://github.com/therecipe/qt/wiki/Deploying-macOS-to-Windows-32-bit-Shared
交叉编译,总结如下:(过程曲折啊,建议仔细看官方文档和wiki,浪费了好多时间。3天,Linux和Mac,Windows都测试了,windows最难搞,不建议配置,建议使用linux开发,交叉编译到windows)
1. 安装QtCreate生成UI文件
2. 使用gouic转化*.ui --> *.go文件,界面文件转化为go源代码
3. 下载therecipe/qt docker镜像,使用命令编译
4. 编译成功的文件放置在deploy目录下
## 动态库链接和静态链接方式对比
1. 动态链接,百十个文件依赖,可执行程序1.9M,总文件体积 71MB
2. 静态链接,只生成1个exe可执行程序19MB
Deploying macOS to Windows 32 bit Static
Docker deployment
-
optional: Install Wine if you want to test your Windows application on macOS
-
Install Docker: https://download.docker.com/mac/stable/Docker.dmg
-
Share your GOPATH with docker if it isn't located in some subfolder below
/Users/
,/Volumes/
,/private/
or/tmp/
. -
Pull the target image
docker pull therecipe/qt:windows_32_static
- Deploy your application
qtdeploy -docker build windows_32_static
You should find your deployed application inside the deploy
subfolder.
https://github.com/therecipe/qt/wiki/Deploying-macOS-to-Windows-32-bit-Static
Linux to windows
-----------------------
Deploying Linux to Windows 32 bit Static
Docker deployment
-
optional: Install Wine if you want to test your Windows application on Linux
-
Install Docker: https://store.docker.com/search?offering=community&type=edition or using a package manager
-
If necessary run docker as root
-
Pull the target image
docker pull therecipe/qt:windows_32_static
- Deploy your application
qtdeploy -docker build windows_32_static
https://github.com/therecipe/qt/wiki/Deploying-Linux-to-Windows-32-bit-Static
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析