简体   繁体   English

如何使用 Qt 部署跨平台应用程序?

[英]How to deploy cross-platform applications with Qt?

I have been coding in Qt for few years using MSVC and QtCreator on Windows.我在 Windows 上使用 MSVC 和 QtCreator 在 Qt 中编码几年了。

Now I have decided to move to Linux environment and continue my development under Ubuntu.现在我决定转移到 Linux 环境并在 Ubuntu 下继续我的开发。 I then wish to compile the result on Windows machine for Windows executable, I expect no issues as the Qt code will be platform independent.然后我希望在 Windows 机器上为 Windows 可执行文件编译结果,我希望没有问题,因为 Qt 代码将独立于平台。

So I have all my .cpp, .ui, .h, .pro and other files on Ubuntu, I can compile it from Qt Creator or using command line, and now I wish to deploy for Windows too.所以我在 Ubuntu 上有我所有的 .cpp、.ui、.h、.pro 和其他文件,我可以从 Qt Creator 或使用命令行编译它,现在我也希望为 Windows 部署。 How do I proceed?我该如何进行? Do I copy all files on Windows machine every time and open project in QtCreator on Windows?我是否每次都复制 Windows 机器上的所有文件并在 Windows 上的 QtCreator 中打开项目? Or can I automate this process somehow to be able to use eg a network-shared folder and avoid Windows Qt Creator modifying my code developed under Linux Qt Creator?或者我能否以某种方式自动化这个过程,以便能够使用例如网络共享文件夹并避免 Windows Qt Creator 修改我在 Linux Qt Creator 下开发的代码? There is lack of documentation when it comes to cross-platform deployment, yet this is the key feature advertised by Qt everywhere.在跨平台部署方面缺乏文档,但这是 Qt 到处宣传的关键特性。

Is some code editing needed?是否需要一些代码编辑? What is the best approach in this scenario?在这种情况下最好的方法是什么?

By using version control eg git you commit on Linux env and then checkout and build manually on Windows.通过使用版本控制,例如git,您可以在 Linux env 上提交,然后在 Windows 上手动检出和构建。

And by setting up continuous integration on Windows eg Jenkins , Buildbot you can automate build process so that when you commit to version control on Linux the CI builds automatically on Windows.通过在 Windows 上设置持续集成,例如JenkinsBuildbot,您可以自动化构建过程,这样当您在 Linux 上提交版本控制时,CI 会在 Windows 上自动构建。

Or you can use MXE to cross-compile on Linux for Windows .或者您可以使用 MXE 在 Linux for Windows 上进行交叉编译

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM