17

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.

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

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 Wine be enough to test the cross compiled version (after all the logic is tested in the Linux version)?

  3. Is this a good idea? :-)

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
cube
  • 3,867
  • 7
  • 32
  • 52
  • 6
    If you have a copy of Windows handy, running a VirtualBox instance of it couldn't hurt for testing either. – Amber Aug 06 '09 at 09:37
  • For testing at least Virtual Box is good, of course the best is a Windows installation it self.. Try writing that app in Windows. I like linux my self. but if your Building for Windows. Programming in windows its the best you can do (for windows applications of course). – Fábio Antunes Oct 09 '09 at 00:17

7 Answers7

15

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

As for installers I'd highly recommend 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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Ray
  • 1,585
  • 9
  • 10
  • Qt sucks. Application written in Qt will definitely not look like Windows one and the licensing is not very good. One will have to pay for commercial license some big money to Qt supporting company. This will be the case for linking statically as well. So doing Qt application cross-platform where one needs to pay vs create a native looking application for free... You hopefully get the idea. ;-) – Igor Apr 10 '23 at 14:29
5

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

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

I suggest using Autotools which has very good cross-compilation support and works "natively" with a cross-compiler.

Under Debian for example, running

./configure --host=i586-mingw32msvc

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

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

AsukaMinato
  • 1,017
  • 12
  • 21
Artyom
  • 31,019
  • 21
  • 127
  • 215
  • Is it a disadvantage that we won't be able to use profilers? And more over if I understand correctly the optimization procedures vary considerably from one OS to other. How could I tackle this? Or is it better to get something working and bother about optimization at the `final testing in Windows`, as you have mentioned. – sjsam May 28 '15 at 06:39
4
    • InstallJammer allows 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.

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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
John Barrett
  • 545
  • 4
  • 9
4

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.

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 just Wine.

I'm not a big fan of cross-platform widgets. Like Java applications you generally end up with something that doesn't quite look 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.

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Cruachan
  • 15,733
  • 5
  • 59
  • 112
  • @PeterMortensen, if the OP chooses wxWidgets, it will look and felt like native Windows app. – Igor Apr 10 '23 at 12:13
2

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.

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.

Liran Orevi
  • 4,755
  • 7
  • 47
  • 64
2

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

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

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.

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
MarkR
  • 62,604
  • 14
  • 116
  • 151
0

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.

I use this to produce installs for a few projects.

Evan
  • 18,183
  • 8
  • 41
  • 48
  • 1
    I really find NSIS to be a bad thing. After working or better trying to work with NSIS a couple of days, I feel pain everywhere... It doesn't report errors(nothing like writing a log of everything including errors and commands that did not succeed), variable assignments and usage seems unclear to me. No real fun. – Henning Oct 13 '09 at 21:30
  • I use Inno Setup and it is truly the best. – Nathan Osman Dec 22 '09 at 07:55