Building for mac from a Visual Studio project.
-
I've been given a QT4 visual studio vsxproj solution that I need to compile to run on a Mac but I'm a bit out of my depth being relatively new to QT. I've downloaded the QT5 creator for the mac, and a lot of the source files have 'windows related code, do I need to change this or does QT do this automatically?
Any assistance in converting this project to run on a mac would be appreciated.
-
Hi and welcome to devnet,
No Qt can't automagically convert platform specific code.
The first thing you should do is convert your Visual Studio project to a qmake project (IIRC it's an option you have with Qt's Visual Studio Addin) So you can use it easily on all platforms
Then you can start working on the platform specify code. One solution is to surround it with
@#ifdef Q_OS_WIN
// windows specific code
#endif@And the corresponding Q_OS_OSX etc...
Same thing for includes etc.
Another option you have depending on your code base is to extract the windows specific implementations in their own file so e.g. have
mycoolclass.cpp <- common code
mycoolclass_win.cpp <- specialized for windows
mycoolclass_mac.cpp <- specialized for OS X/iOS
etc…
and only build them when needed. The selection can be done in your pro file. qmake's documentation will help you for thatHope it helps