Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. How to have a project that can compile on multiple platforms
Forum Updated to NodeBB v4.3 + New Features

How to have a project that can compile on multiple platforms

Scheduled Pinned Locked Moved Installation and Deployment
13 Posts 4 Posters 6.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hsfougaris
    wrote on last edited by
    #1

    I'm developing an app that is supposed to run on Windows, Mac and Linux.
    As every now and then I would like to verify everything on all platforms, I have done the following to enable me to just compile it (the code is in a shared folder):

    • disabled shadow builds
    • added the following to my .pro file:
      @
      win32 {
      DESTDIR = ../build-Win32
      MOC_DIR = ../build-Win32/moc
      OBJECTS_DIR = ../build-Win32/obj
      }
      macx {
      DESTDIR = ../build-OSX
      MOC_DIR = ../build-OSX/moc
      OBJECTS_DIR = ../build-OSX/obj
      }
      unix:!macx {
      DESTDIR = ../build-Linux
      MOC_DIR = ../build-Linux/moc
      OBJECTS_DIR = ../build-Linux/obj
      }
      @
      This seems to work.

    The problem I'm facing is with the user settings file.
    I don't know how to control that (it seems to be autogenerated), and because I can't use the same one on my different platforms I have to say no (which means don't use) when opening the project and it complains that the user settings is not compatible, so it creates a new one which I have to tweak every time I open the project in a different platform.

    Can this be handled more gracefully?

    If you can't say what you mean, you'll never be able to mean what you say.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tobias.hunger
      wrote on last edited by
      #2

      Have you tried shadow building (building outside the source tree) instead of this hackery?

      E.g.:
      @
      mkdir qt-creator-linux-build
      cd qt-creator-linux-build
      qmake ../qt-creator/qt-creator.pro
      @
      Note that the build directory currently has to be the same distance from the root as the source directory (so it has to be next to the source).

      Qt Creator will support you with setting this up.

      1 Reply Last reply
      0
      • H Offline
        H Offline
        hsfougaris
        wrote on last edited by
        #3

        How would that be setup in QtCreator (because I tried and that's what I ended up with my solution).

        But even if it works, I don't think it will resolve the issue with user settings file, as it seems to be platform specific.

        If you can't say what you mean, you'll never be able to mean what you say.

        1 Reply Last reply
        0
        • F Offline
          F Offline
          florent.revelut
          wrote on last edited by
          #4

          What we do here, we develop on one platform and we delegate building to controlled environment (buildbox, like cruisecontrol).
          This way, you an independant status of your project, on all platforms that you want to support which reflects exact status of your configuration management.
          Another solution is to build using command line, which doesn't care about "user preferences", which are for QtCreator only:
          @
          qmake -r
          make (or nmake on windows/VC)
          @

          Hope this helps,

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

            How do you distribute your code between the different platforms?

            Your xxx.pro.user problem is only an issue, if you copy complete directories or use a shared directory (probably via a network volume/drive). Both are a Bad Idea™...

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0
            • H Offline
              H Offline
              hsfougaris
              wrote on last edited by
              #6

              I am using a network drive, since it is part of a very thorough backup policy. Why is that a bad idea?

              If you can't say what you mean, you'll never be able to mean what you say.

              1 Reply Last reply
              0
              • G Offline
                G Offline
                goetz
                wrote on last edited by
                #7

                Because you easily can mess up things, let alone modifying one source file on two editors simultaneously.

                I strongly suggest using some (distributed) source code management system for synchronizing things. I personally use mercurial for this, but git and bazaar do the trick too. I would avoid introducing subversion or even CVS on new projects nowadays. They all work on filesystems too. So you can use the network drive as a kind of "central repository" where the actual exchange happens.

                This way you have the advantage that no .pro.user files are checked in and you can manage them on their respective platforms.

                And as a minor advantage: With distributed source control management, you have (at least paratial) backups on every machine involved.

                And everyone wants to have their source code in a SCM anyways, won't they? :-)

                http://www.catb.org/~esr/faqs/smart-questions.html

                1 Reply Last reply
                0
                • H Offline
                  H Offline
                  hsfougaris
                  wrote on last edited by
                  #8

                  I guess you're right, even though I'm the only one working on this project.
                  So in this scenario, I'd keep my .pro as it is, and just not check in the .pro.user files?

                  If you can't say what you mean, you'll never be able to mean what you say.

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    goetz
                    wrote on last edited by
                    #9

                    [quote author="hsfougaris" date="1301672624"]I guess you're right, even though I'm the only one working on this project.
                    So in this scenario, I'd keep my .pro as it is, and just not check in the .pro.user files?[/quote]

                    Yep! That's exactly what I do here too.

                    http://www.catb.org/~esr/faqs/smart-questions.html

                    1 Reply Last reply
                    0
                    • H Offline
                      H Offline
                      hsfougaris
                      wrote on last edited by
                      #10

                      [quote author="Volker" date="1301673063"][quote author="hsfougaris" date="1301672624"]I guess you're right, even though I'm the only one working on this project.
                      So in this scenario, I'd keep my .pro as it is, and just not check in the .pro.user files?[/quote]

                      Yep! That's exactly what I do here too.[/quote]

                      How exactly do you configure Qt on the "other" computers to use the distributed SCM?
                      I installed mercurial on my main development PC, created a repository, configured it in QtCreator, and everything works fine...
                      I run hg serve on this PC.
                      I can pull from the command line of the other PC the project, but what would I specify so it does all this automating pulling/committing (when requested) to the remote repository?
                      (I'm new to this so forgive me if this is a stupid question)

                      If you can't say what you mean, you'll never be able to mean what you say.

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        goetz
                        wrote on last edited by
                        #11

                        You could write a script, that is called before make start. But I do not recommend this. Some time you will eventually end up with having modified the sources on both machines. In my opinion, syncing manually is a more reliable approach in this case (think of merge conflicts that need manual resolution).

                        On Windows, I use "TortoiseHg":http://tortoisehg.bitbucket.org/ - command line tools on Windows are... ahm.. suboptimal to use :-) They have a Mac OS X port too, but I never tried this - OS X command line (bash to be precise) is a joy to work with.

                        http://www.catb.org/~esr/faqs/smart-questions.html

                        1 Reply Last reply
                        0
                        • F Offline
                          F Offline
                          florent.revelut
                          wrote on last edited by
                          #12

                          Agreed with Volker : pre build hook to sync your files can lead to madness.

                          My advice, if you really want to have a per-commit build on all platforms : put cruise control (or any other continuus integration tool) in place and let it listen to your repository.

                          This way, each time you commit (or on demand), you can trigger a build on all your platforms, with an environment which is under better control.

                          On a side note, compared to using shared environment on a folder, using a version control manager allows you to revert mistakes :-)

                          1 Reply Last reply
                          0
                          • G Offline
                            G Offline
                            goetz
                            wrote on last edited by
                            #13

                            The Mercurial/Creator specific part has been moved to "this thread":http://developer.qt.nokia.com/forums/viewthread/4932/

                            http://www.catb.org/~esr/faqs/smart-questions.html

                            1 Reply Last reply
                            0

                            • Login

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved