Results 1 to 9 of 9

Thread: Multiple platforms

  1. #1
    Join Date
    Jan 2010
    Posts
    23
    Qt products
    Qt4
    Platforms
    Windows

    Default Multiple platforms

    Hey guys,

    I can't figure out how to move my code from one platform to another. A project I'm working on requires that the code be written on a windows machine but ran on linux/mac. Can someone tell me how I can build my application (or somehow copy the project) so that it can be distributed to a linux/mac computer?

  2. #2
    Join Date
    Sep 2009
    Posts
    72
    Thanked 10 Times in 10 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi
    Platforms
    Unix/X11 Windows

    Default Re: Multiple platforms

    Hi

    Here i am assuming few things,correct me if i am wrong.
    1. You have Qt project
    2. in which you do not have any platform dependent code other than Qt code. If you have platform dependent code then you can use Q_WS_WIN, Q_WS_MAC, Q_WS_X11 micros in #ifdef
    3. Your Qt project has .pro file

    if all the cases are correct from above then you really dn't have to very much about it. you can follow the same build process on mac and linux as you followed on windows. i.e. qmake, nmake (on windows) / make (mac and linux)

    For Qt installation on Mac/Linux refer Qt site.

  3. #3
    Join Date
    Jan 2010
    Posts
    23
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Multiple platforms

    Thanks for the reply. I'm using Qt Creator for most of my projects -- is there a way to do it through that?

  4. #4
    Join Date
    Feb 2010
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Multiple platforms

    I think there is some confusion now between compiling on the host platform and cross-compiling. Cross-compiling means that you compile the program for another target platform then the one you are compiling on (the host platform).

    Qt says about cross-compiling (in the FAQ):
    Cross compiling the Qt package is not something we support. Qt is not designed to be cross compiled so we don't actually test if this is possible. Due to the nature of Qt, some parts must be built natively in order for it to cross compile such as qmake, moc and uic which are used during compilation. We do not test this scenario internally and therefore do not guarantee it would work.
    So you better get yourself a Mac and install linux on your pc (can be done with dual boot so you can keep windows on it). Then install Qt on both operating systems and compile!

    If you don't want to do this, start searching for 'cross compiling' with google. But its probably easier to go for the first solution.

    Joost

  5. #5
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Multiple platforms

    At least for the linux part I would suggest www.virtualbox instead of dualbooting. You can download fully configured linux machines, so that you don't even have to install it yourself.

    I just googled "virtualbox MacOSX" and came up with this forum: http://forums.virtualbox.org/viewtopic.php?t=2076 . It may be a starting point. Although the legal aspects have to be thoroughly considered!

    To get back to the question: You would then install QtCreator on those platforms and compile your projects natively. So you avoid the problem of cross-compiling.

    Johannes

  6. #6
    Join Date
    Jan 2010
    Posts
    23
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Multiple platforms

    Thanks for the replies everyone -- so I understand now that I cannot cross-compile my projects. However, is there a way to easily transfer a project written in Windows to Linux (e.g., write the project in Windows, transfer, and compile the same project in Linux)?

    Thanks again for the support

  7. #7
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Multiple platforms

    there is no easy way. there is only one way. just copy your whole source dir to linux machine and compile. If you dont have windows specific code like hardcoded paths ("C:\Windows", type) and win32 api calls then you are done.

  8. #8
    Join Date
    Jan 2010
    Posts
    23
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Multiple platforms

    Ok - we tried this but got an error. I'll post the error message next time I'm at the workstation. Thanks

  9. #9
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Multiple platforms

    assuming you took some care to use portable code, i.e. use Qt API everywhere to hide platform specific code or #ifdef, the process is simple.
    An example to copy a project from windows to linux:
    1) delete debug/release folders
    2) delete Makefile, Makefile.Debug, Makefile.Release
    3) delete object_script*.*
    4) delete <project>.pro.user
    5) copy the entire folder
    6) open the <project>.pro file with Qt Creator on linux
    7) build all

    note: if you link any 3rd party libs, then you need to specify the differences in your .pro file like so (example):
    unix:LIBS += -l/location/of/lib/linux/libwhatever.a
    win32:LIBS += c:/location/of/lib/win/libwhatever.a

Similar Threads

  1. How to unify the QT style in different platforms?
    By yangyunzhao in forum Qt Programming
    Replies: 7
    Last Post: 5th August 2009, 11:23
  2. Compile binaries for all platforms from windows
    By aleksjej in forum Qt Tools
    Replies: 2
    Last Post: 2nd June 2009, 12:34
  3. send OS signals to apps on all platforms
    By Morea in forum Qt Programming
    Replies: 3
    Last Post: 21st November 2008, 22:00
  4. What platforms are you using Qt on?
    By gfunk in forum Qt Programming
    Replies: 7
    Last Post: 8th February 2007, 15:47
  5. Compiling on different platforms
    By Tori in forum Newbie
    Replies: 1
    Last Post: 25th January 2006, 22:09

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.