0

I have a Windows program that writen in QT using C++. May I know whether those code wrote for Windows platform are convertible to Mac? Is it 100% of the code are convertible or none of it are convertible?

5
  • 2
    Qt is a cross-platform framework. The changes should be very minor and evident in the documentation if any. In my experience going from windows to linux in Qt all I had to do was compile it again on the other machine and everything worked fine.
    – AJG85
    Jun 29, 2011 at 13:52
  • It's quite possible to write C++ code that works on both platforms, but sadly it's also easy to write code that only works on particular versions of a particular system...
    – user395760
    Jun 29, 2011 at 13:55
  • 2
    Have you tried compiling your code before asking here? Jun 29, 2011 at 18:23
  • @Serge Dundich: so sorry for this because I am in proposing stage and I don't have Mac machine, thus I can't carry out any experiment on this. In order to save cost, I had try bing, google, and yahoo group before I acquire the MAC, found out that no people doing this kind of conversion work before. If this can't be done, my proposal gonna be drop.
    – huahsin68
    Jun 30, 2011 at 2:12
  • 1
    "found out that no people doing this kind of conversion work before" How did you get to this conclusion? We did it on our project (and I think very lots of people did). For a well-written QT program you have to just recompile and create installation package. If the program is not so good you may port it even without Mac machine - search for Microsoft-specific code (you can remove all windows #includes and compiler will reveal it for you in a form of compilation errors) and port it to crossplatform QT-based code. Jun 30, 2011 at 6:15

2 Answers 2

8

Go for the brute force approach, IMO.

Download the Mac SDK

Install, open the project, compile.

If it fails, check the code for platform specific stuff.

It's not "smart" but it's effective since you will need to download the SDK anyway if you plan on coding for mac.

(Note that this is not a cross-compiler, I'm assuming you have a mac to develop on)

3
  • Is this means MAC can do C++ compilation beside objective-C?
    – huahsin68
    Jun 30, 2011 at 2:13
  • 2
    Macs are general purpose computers, they can compile (do) anything given the appropriate compiler (software) :P Jun 30, 2011 at 2:15
  • 1
    Mac OS X Snow Leopard has an in-built gcc provided by Apple - it's not the latest release (something like 4.3) but usually works fine. XCode (the native Apple development system) and QtCreator use this gcc - thus they can compile C, C++, objectiveC ...
    – Jens
    Jun 30, 2011 at 8:01
7

There are a couple of things that are different on the Mac

  • the Installer of your application needs to be written from scratch (if you have on)
  • Windows API calls need to be ported (if there are any)
  • file associations (e.g. .doc means call WinWord.exe) are done differently on Mac OS
  • double clicking an associated file is implemented differently (not via argv as in Windows)
  • the menus are different (the default menu contains for example the About Box, whereas the About Box in Windows is usually located under the Help Menu) - note that this can be expressed in native, good QT, but usually, Windows programmers forget to implement menus cleanly)
  • and so on.

So my conclusion would be: While it is possible to write clean Qt code which can be 100% ported from one OS to another, usually, programmers fail to do it 100% clean and thus there will be some porting work to be done.

As hexa recommends, go ahead, compile the stuff and try to sort the errors into categories. Once you have these categories, make your decision on how to proceed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.