在 Linux 上开发 Windows 应用程序?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1237898/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 12:57:15  来源:igfitidea点击:

Developing Windows applications on Linux?

windowslinuxinstallercross-platformwxwidgets

提问by cube

My primary OS is Linux, but now I'm forced to write some C++ applications for Windows. I was thinking about developing on the Linux box with cross platform libraries like WxWidgets (and some care about other platform dependencies) and then cross compiling the result to mingw target.

我的主要操作系统是 Linux,但现在我不得不为 Windows 编写一些 C++ 应用程序。我正在考虑在 Linux 机器上使用 WxWidgets 等跨平台库(以及一些关心其他平台依赖项)进行开发,然后将结果交叉编译到 mingw 目标。

So the tools I'm thinking of using are

所以我正在考虑使用的工具是

  • g++ for compilation and cross-compilation.
  • CMake
  • WxWidgets
  • ??? for making windows installer packages
  • wine for testing of the windows version
  • g++ 用于编译和交叉编译。
  • 制作
  • 窗口小部件
  • ???用于制作 Windows 安装程序包
  • 用于测试 windows 版本的 wine

And my questions:

我的问题:

  1. What are some free (or even better open source) installers for Windows that I might use to create the final package? It would help if the package could be prepared from Linux.

  2. Will Winebe enough to test the cross compiled version (after all the logic is tested in the Linux version)?

  3. Is this a good idea? :-)

  1. 我可能会使用哪些免费(甚至更好的开源)Windows 安装程序来创建最终包?如果可以从 Linux 准备该软件包,将会有所帮助。

  2. 是考不上的交叉编译版本(所有的逻辑在Linux版本的测试之后)?

  3. 这是一个好主意吗?:-)

回答by Ray

Check Qt too. It's a very rich cross-platform framework.

也检查 Qt。这是一个非常丰富的跨平台框架。

As for installers I'd highly recommend WiX.

至于安装人员,我强烈推荐WiX

For testing it will be much better to use some kind of virtualization like Sun Microsystems's VirtualBox. I believe you could use a trial version of Windows or Windows 7 RC, which is free to use until March 2010.

为了进行测试,最好使用某种虚拟化,例如 Sun Microsystems 的 VirtualBox。我相信你可以使用 Windows 或 Windows 7 RC 的试用版,它可以免费使用到 2010 年 3 月。

回答by Artyom

First of all, yes it is good idea. I have several projects that I maintain their Windows version in this way.

首先,是的,这是个好主意。我有几个项目以这种方式维护它们的 Windows 版本。

In any case, I suggest you test the final product on Windows machine. If you have a license for Windows OS, you may use virtualization to do final tests.

无论如何,我建议您在 Windows 机器上测试最终产品。如果您拥有 Windows 操作系统的许可证,则可以使用虚拟化进行最终测试。

I suggest to use Autotoolsthat has very good cross compilation support and works "natively" with a cross compiler.

我建议使用Autotools,它具有非常好的交叉编译支持并且可以与交叉编译器“本地”工作。

Under Debian for example running

例如在 Debian 下运行

./configure --host=i586-mingw32msvc

This would create the correct cross compilation makefile as if this was Unix project.

这将创建正确的交叉编译 makefile,就像这是 Unix 项目一样。

In any case, I would recommend to develop a cross platform version and time-to-time test native Windows version with Wine/Windows by cross compiling them.

在任何情况下,我都会建议通过交叉编译它们来开发跨平台版本和使用 Wine/Windows 不时测试本机 Windows 版本。

回答by Cruachan

You imply that the applications are for Windows only and not cross-platform, in which case I think the answer to 3. - This is really not a good idea - trumps the rest.

您暗示应用程序仅适用于 Windows 而不是跨平台的,在这种情况下,我认为 3 的答案。 - 这真的不是一个好主意 - 胜过其余部分。

The reason being you are going to have to extensively test the application under Windows anyway, either directly or in a virtual instance. That being so you're better to develop under the target OS because you're more likely to produce a better application - both from catching the bugs earlier and more thoroughly and ensuring your application 'works' for your users. I certainly wouldn't trust justWine.

原因是您无论如何都必须在 Windows 下直接或在虚拟实例中广泛测试应用程序。因此,您最好在目标操作系统下进行开发,因为您更有可能开发出更好的应用程序 - 从更早、更彻底地捕获错误以及确保您的应用程序为您的用户“工作”。我当然不会相信Wine

I'm not a big fan of cross-platform widgets. Like Java applications you generally end up with something that doesn't quitelook right, and like the uncanny gap that can be enough to make your application smell bad to a large section of your users. Even at the slightly more abstract level, each OS's applications have a slightly different feel as to how they work and you'll most likely end up with a Windows application that feels like a, say, KDE one, which will again put your users off.

我不是跨平台小部件的忠实粉丝。与 Java 应用程序一样,您通常最终会得到一些看起来不太对劲的东西,并且就像离奇的差距足以让您的应用程序对大部分用户产生不好的感觉。即使在更抽象的层次上,每个操作系统的应用程序对它们的工作方式也有略微不同的感觉,你很可能最终会得到一个感觉就像 KDE 应用程序的 Windows 应用程序,它会再次让你的用户失望.

So yes, certainly possible to do this, but probably not the optimal approach from point of view of the quality of the end product. To do so will give yourself something of a handicap with what you produce and I'd say that's likely to offset the convenience to you of using a Linux platform. Actually I'd be surprised if you manage even that because I'd bet you'll spend more time messing around with the widgets trying to fine-tune them so they work right under real Windows than you'll gain from using an unfamiliar Windows toolset.

所以是的,当然可以做到这一点,但从最终产品的质量角度来看,这可能不是最佳方法。这样做会给您自己生产的产品带来一些障碍,我认为这可能会抵消使用 Linux 平台给您带来的便利。实际上,如果您做到这一点,我会感到惊讶,因为我敢打赌,与使用不熟悉的 Windows 相比,您会花更多的时间来处理这些小部件,试图对它们进行微调,以便它们在真实的 Windows 下正常工作工具集。

回答by John Barrett

    • InstallJammerallows you to create installers for *nix and Windows. I am not sure if it allows cross creation of installers (i.e. creating Windows installers from *nix). A commercial option with demo available to try is the Bitrock InstallBuilder.
    • Maybe... If you have a Windows license, Dav's suggestion would be better.
    • If it helps you work better/more efficiently & effectively, sure.
    • InstallJammer允许您为 *nix 和 Windows 创建安装程序。我不确定它是否允许交叉创建安装程序(即从 *nix 创建 Windows 安装程序)。可以试用的带有演示的商业选项是Bitrock InstallBuilder
    • 也许...如果您有 Windows 许可证,Dav 的建议会更好。
    • 如果它可以帮助您更好/更高效地工作,那当然可以。

Keep us posted on how you get on - this is interesting.

让我们了解您的进展情况 - 这很有趣。

回答by Liran Orevi

2) No, Wine as it says is not Windows, you can not reliably test it like that. I suggest running a Virtual machine in your Linux, that will make your work much smoother.

2) 不,正如它所说的 Wine 不是 Windows,你不能像那样可靠地测试它。我建议在您的 Linux 中运行一个虚拟机,这将使您的工作更加顺畅。

3) It sounds possible, for the graphical aspect I would also consider GTK+which was used for GIMP, and works much the same on Windows and Linux.

3) 听起来可能,对于图形方面,我还会考虑用于GIMP 的GTK+,并且在 Windows 和 Linux 上的工作方式大致相同。

回答by MarkR

You will need an MSDN licence anyway to get access to all the multitude of versions of Windows you'll want to test on.

无论如何,您都需要一个 MSDN 许可证才能访问您要测试的所有众多版本的 Windows。

You'll want to install the test OSs on VMs. This could be on your Linux desktop, but a dedicated box might be better.

您需要在 VM 上安装测试操作系统。这可能在你的 Linux 桌面上,但一个专用的盒子可能会更好。

I don't know how many versions of Windows you plan on supporting, but you should definitely test on all of them. Wine is not Windows, nor is Windows XP the same as Windows Vista, Windows 7, etc. There are also a lot of different distributions and languages of Windows, some of which you should undoubtedly test on.

我不知道您计划支持多少个 Windows 版本,但您绝对应该对所有版本进行测试。Wine 不是 Windows,Windows XP 也不等同于 Windows Vista、Windows 7 等。Windows 也有许多不同的发行版和语言,您无疑应该测试其中的一些。

By all means, develop on Linux. By all means, use cross-platform widgets (yes, these are good). But you'll still need your MSDN licence so you can install test OSes.

无论如何,在 Linux 上开发。无论如何,使用跨平台小部件(是的,这些都很好)。但是您仍然需要您的 MSDN 许可证才能安装测试操作系统。

回答by Evan

NSIS, the Nullsoft Scriptable Install System can be compiled under Linux and used to produce install binaries for Windows. The instructions are here. Read the general section, and the section for building on POSIX.

NSIS,Nullsoft Scriptable Install System 可以在 Linux 下编译并用于为 Windows 生成安装二进制文件。说明在这里。阅读一般部分和在 POSIX 上构建的部分。

I use this to produce installs for a few projects.

我用它来为一些项目生成安装。