How to port an MFC application to Mac OS X

Most of the software I write is Windows only, but there are a lot of people who want it to run on MacOS as well. I ported irrKlang to Mac OS X some time ago, but it's only a software library and not an application, so I didn't have that much experience when I thought it would be a good idea to port the irrfuscator frontend to Mac. Unfortunately, that program was written in MFC, basically a set of classes wrapped around the Win32 API. The irrFuscator frontend looked like this:


And if you know a bit of the internals of the MFC, Microsoft made it really hard to port code using this framework to another operating system. But after some few days, irrFuscator looked like this:


It finally ran and worked on Apple's operating system, yay! So, how did I do that?

Basically, I didn't port the MFC application at all. I stripped out every MFC dependency and replaced it with wxWidgets, a free and open source cross platform UI library. The API of wxWidgets is very similar to the MFC, so this was quite easy, and I was able to port every feature of the frontend to wxWidgets surprisingly without much effort. The result was a code based on wxWidgets which compiles both with gcc/XCode and with Microsofts VisualStudio, which is great: Only one codebase to maintain for bug fixes, new features, etc.

So I can really recommend wxWidgets for crossplatform application development. You can try out both versions of irrfuscator here, if you are interested.

nine comments, already:

I used to love WxWidgets for cross-platform development, until recently the QT libraries have become LGPL – they have quickly become my favourite framework…
Sickbyte - 19 06 09 - 19:02

Agreed. I’ve used wxWidgets and Qt, and while wx is nice, Qt is more powerful. While Qt was a choice between GPL or 2K per platform/seat commercial, wxWidgets was my preferred choice (unless a customer was paying for the Qt license :), but now Qt is LGPL I would definitely choose that first.
steve () (link) - 19 06 09 - 20:27

I agree 100% with steve, wxWidgets was used because of Qt license. Now QT is the best cross platform and it’s free.
The only downside is that it’s not a light framework, but who cares those days.
ASpanishGuy - 19 06 09 - 23:02

Yes, but the wxWidgets license still is a lot better than LGPL, especially if you want to link statically with it.
niko - 20 06 09 - 11:14

I think the license differences are incredibly minor, despite what wxWidgets may have you believe. Static linking is the only genuine difference, but the vast, vast majority of people use Qt with dynamic linking – it’s been the default option for binary releases of Qt since forever, and the way that 99% of people use it.
steve () (link) - 20 06 09 - 17:15

@steve, But static Linking too has it benefits. “Now you can link OGRE3D statically also under our new modified license”, though I personally like this license scheme better. the only problem with LGPL is static linking.
kinjalkishor () - 20 06 09 - 18:44

I further agree on the benefits of using wxWdigets, but QT has now become my GUI library of choice since the license change. I have never found the need to use static linking, and in fact like QT using the LGPL, since it forces community members to contribute their patches and improvements. A couple things I like about QT:
Theming – native OS look or customizable. Now supports GTK+ look on Linux, too.
CSS styles – Belongs with theming, but deserves separate mention for its innovativeness.
QtCreator – great IDE for rapid development
Webkit – Extremely useful for a variety of applications. I love being able to expose native QT widgets to the web page.

Don’t get me wrong; wxWidgets still has many, many positives, but I feel that QT has even more. One thing I really miss about wxWidgets, however, is the AUI windowing interface. QT has something similar, but it isn’t as quite as good. ;-)
irrdev - 21 06 09 - 12:03

niko: Did you do the design of your app with a designer application or by code? Because as I recall wxWidgets does not have a GUI designer for Visual Studio..
MasterGod () (link) - 21 06 09 - 19:51

Did it by hand, but wasn’t that much effort.. :)
niko - 22 06 09 - 16:49


Name:  
Remember personal info?
yes
no
Email (optional):
URL (optional):
Enter "layered" (antispam):
Comment:Emoticons / Textile

  ( Register your username / Log in )

Notify: Yes, send me email when someone replies.  

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.
Note: If you type in your email adress above, it will be visible to other visitors, although it will be hidden for bots using javaScript.