Cross Platform Development



  • I've read through the forums and my apologies if I've missed this. My goal is to develop a cross-platform app for Windows and Linux. I know that in order to compile for Linux I must do so under the QT version for Linux. My question is in regards to development of the app.

    If I develop the app under QT for Windows and save it as a QT project file can I open that QT project file under QT for Linux and compile under Linux to make the Linux version of the app? Or do I have to develop the Linux version of the app from scratch under QT for Linux?



  • [quote author="krackerjax" date="1367363366"]I've read through the forums and my apologies if I've missed this. My goal is to develop a cross-platform app for Windows and Linux. I know that in order to compile for Linux I must do so under the QT version for Linux. My question is in regards to development of the app.

    If I develop the app under QT for Windows and save it as a QT project file can I open that QT project file under QT for Linux and compile under Linux to make the Linux version of the app? Or do I have to develop the Linux version of the app from scratch under QT for Linux?[/quote]

    The answer is simple: "Code once, compile anywhere." Which means that you don't need to start again from scratch or do some revisions (but there are times you have to do some minor revision like platform-specific stuff).

    And by the way, it is "Qt" and NOT "QT"(QuickTime). There is a very big difference between the m.


  • Moderators

    In theory you just need to develop your project on either Linux or Windows and then build it once for the other platform once you are done developing. A .pro-file should work on Windows, Linux and Mac, but you usually will tweak the build for a platform/compiler by introducing scopes.

    In practice you will want to switch between the platforms regularly: It is so easy to introduce some OS or compiler specific code that will break the build for one or more platforms. When working in a team having one developer work on windows, one on Linux and one on Mac is a common pattern and developers should be encouraged to use different compilers (or versions thereof) and platforms if you care for cross-platform compatibility. A continuous integration system can also help detect incompatibilities early.

    I would also encourage you to try to write your code in such a way that as much of it is build on all platforms as possible, even if it might not make too much sense. The compiler will catch many errors and having it see as much code as possible is a great help when refactoring. In creator we use https://qt.gitorious.org/qt-creator/qt-creator/blobs/master/src/libs/utils/hostosinfo.h in favor of preprecessor defines for this reason.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.