Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Write Qt code once and compile it on many platforms
Forum Updated to NodeBB v4.3 + New Features

Write Qt code once and compile it on many platforms

Scheduled Pinned Locked Moved Solved General and Desktop
17 Posts 6 Posters 2.1k Views 2 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.
  • tomyT tomy

    @VRonin
    So if we aim at having our program for some other platform too, we just add its kit to our Qt Creator and re-compile the code by that kit. Right?

    @jsulm,
    Got it.

    Thanks to both of you.
    But one subtle point here, I think for platforms like iOS and Android which are mostly running on smartphones, it's better to write code using QML not Qt.

    VRoninV Offline
    VRoninV Offline
    VRonin
    wrote on last edited by
    #6

    @tomy said in Write Qt code once and compile it on many platforms:

    So if we aim at having our program for some other platform too, we just add its kit to our Qt Creator and re-compile the code by that kit. Right?

    Yes, but. As @jsulm correctly pointed out cross compiling (i.e. compile on one operating system for another) can become complicated very fast, especially on windows host.

    The fastest way is to set up a clear build process (qmake or CMake are perfect for this) and set up a CI system with different hosts compiling for each target.

    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
    ~Napoleon Bonaparte

    On a crusade to banish setIndexWidget() from the holy land of Qt

    tomyT 1 Reply Last reply
    0
    • VRoninV VRonin

      @tomy said in Write Qt code once and compile it on many platforms:

      So if we aim at having our program for some other platform too, we just add its kit to our Qt Creator and re-compile the code by that kit. Right?

      Yes, but. As @jsulm correctly pointed out cross compiling (i.e. compile on one operating system for another) can become complicated very fast, especially on windows host.

      The fastest way is to set up a clear build process (qmake or CMake are perfect for this) and set up a CI system with different hosts compiling for each target.

      tomyT Offline
      tomyT Offline
      tomy
      wrote on last edited by tomy
      #7

      @VRonin

      (qmake or CMake are perfect for this) and set up a CI system with different hosts compiling for each target.

      Will you explain it a little more, or simpler.
      What do you mean by a CI, then, please?

      aha_1980A 1 Reply Last reply
      0
      • tomyT tomy

        @VRonin

        (qmake or CMake are perfect for this) and set up a CI system with different hosts compiling for each target.

        Will you explain it a little more, or simpler.
        What do you mean by a CI, then, please?

        aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by
        #8

        @tomy

        What do you mean by a CI, then, please?

        A Continuous Integration system, like Jenkins

        Qt has to stay free or it will die.

        1 Reply Last reply
        2
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by VRonin
          #9

          CI = Continuous Integration

          For open source programs you can use for free Appveyor for Windows and Travis for Linux and OSX. From the Ubuntu host you can also cross compile for android. I never tested the OSX image compiling for iOS but should be doable.
          For the chat example we set up a bare bones CI system to make sure that the code compiles everywhere but those platforms allow you to also run unit tests and automate the deployment

          Qt itself uses a a CI system called Coin

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          3
          • SPlattenS Offline
            SPlattenS Offline
            SPlatten
            wrote on last edited by SPlatten
            #10

            I've worked on projects where the target Operating System was RedHat Linux, another developer also working on the same system was using a Windows laptop and Windows 7 to develop and test on, the source code did not have any differences in, however we did have different project files to build for each platform.

            This was a few years ago using Qt 5.6

            Kind Regards,
            Sy

            VRoninV 1 Reply Last reply
            0
            • SPlattenS SPlatten

              I've worked on projects where the target Operating System was RedHat Linux, another developer also working on the same system was using a Windows laptop and Windows 7 to develop and test on, the source code did not have any differences in, however we did have different project files to build for each platform.

              This was a few years ago using Qt 5.6

              VRoninV Offline
              VRoninV Offline
              VRonin
              wrote on last edited by
              #11

              @SPlatten said in Write Qt code once and compile it on many platforms:

              however we did have different project files to build for each platform.

              This should not be necessary, a few ifs in the project file (either qmake or cmake) should be more than enough to have 1 project for every platform.

              Visual Studio merges the source structure of the IDE and the build system so sometimes it's just less of a hassle to have a separate vcproj file however it's not advisable for big projects. some careful configuration of CMake allows you to provide VS developers with perfectly usable project files

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              1 Reply Last reply
              5
              • SPlattenS Offline
                SPlattenS Offline
                SPlatten
                wrote on last edited by
                #12

                Sorry, my error, we didn't have multiple project files but we did have conditions in the same file for different operating system builds.

                Kind Regards,
                Sy

                1 Reply Last reply
                1
                • tomyT Offline
                  tomyT Offline
                  tomy
                  wrote on last edited by tomy
                  #13

                  @VRonin

                  The Wikipedia page was not clear enough for me; rather baffling actually! I read the introduction of this page for that topic. It seems that CI is for sharing projects mostly. A sharing project or some integration to build a better app was not in question. I don't know why you pointed to that. I look forward to seeing your helpful intention about that and will talk about it more afterwards.

                  But as a plan B, what do you think of this please:

                  • Using Qt Creator on Windows for Windows programs
                  • If there's an interesting program on Windows, I simply copy its code and paste on the Linux Qt Creator and compile it there to have its Linux version.
                  • Building Android projects using the Arm7 kit on Windows for Android apps using QML.
                  • For other Oses, like iOS, since there isn't any MacOSX machine to my hands, I have to bow out of that purpose until I get such a machine and then on that will go for producing iOS apps.
                  aha_1980A 1 Reply Last reply
                  0
                  • tomyT tomy

                    @VRonin

                    The Wikipedia page was not clear enough for me; rather baffling actually! I read the introduction of this page for that topic. It seems that CI is for sharing projects mostly. A sharing project or some integration to build a better app was not in question. I don't know why you pointed to that. I look forward to seeing your helpful intention about that and will talk about it more afterwards.

                    But as a plan B, what do you think of this please:

                    • Using Qt Creator on Windows for Windows programs
                    • If there's an interesting program on Windows, I simply copy its code and paste on the Linux Qt Creator and compile it there to have its Linux version.
                    • Building Android projects using the Arm7 kit on Windows for Android apps using QML.
                    • For other Oses, like iOS, since there isn't any MacOSX machine to my hands, I have to bow out of that purpose until I get such a machine and then on that will go for producing iOS apps.
                    aha_1980A Offline
                    aha_1980A Offline
                    aha_1980
                    Lifetime Qt Champion
                    wrote on last edited by
                    #14

                    @tomy Your plan B is perfectly fine.

                    A CI system however, automates that. You develop on your Windows machine, check in a new revision into the version control system and the CI automatically builds the Linux, mac, Android, iOS version for you.

                    Regards

                    Qt has to stay free or it will die.

                    tomyT 1 Reply Last reply
                    3
                    • aha_1980A aha_1980

                      @tomy Your plan B is perfectly fine.

                      A CI system however, automates that. You develop on your Windows machine, check in a new revision into the version control system and the CI automatically builds the Linux, mac, Android, iOS version for you.

                      Regards

                      tomyT Offline
                      tomyT Offline
                      tomy
                      wrote on last edited by
                      #15

                      @aha_1980

                      You develop on your Windows machine, check in a new revision into the version control system and the CI automatically builds the Linux, mac, Android, iOS version for you.

                      Wow, that would be great if it were that easy as it seems. :)

                      A couple of questions:
                      1- Can it work as good as the plan B?
                      2- Are you sure using a CI system, say, on Windows, it's feasible to create apps for iOS too? (I mean, without a real Apple machine)

                      aha_1980A 1 Reply Last reply
                      0
                      • tomyT tomy

                        @aha_1980

                        You develop on your Windows machine, check in a new revision into the version control system and the CI automatically builds the Linux, mac, Android, iOS version for you.

                        Wow, that would be great if it were that easy as it seems. :)

                        A couple of questions:
                        1- Can it work as good as the plan B?
                        2- Are you sure using a CI system, say, on Windows, it's feasible to create apps for iOS too? (I mean, without a real Apple machine)

                        aha_1980A Offline
                        aha_1980A Offline
                        aha_1980
                        Lifetime Qt Champion
                        wrote on last edited by
                        #16

                        @tomy You would probably set up multiple servers on different operating systems. But that could be in a computing center, so you would not have to care for the hardware.

                        Probably you can buy such things as on-demand service, I've never searched but I'm sure such service exists.

                        Qt has to stay free or it will die.

                        tomyT 1 Reply Last reply
                        1
                        • aha_1980A aha_1980

                          @tomy You would probably set up multiple servers on different operating systems. But that could be in a computing center, so you would not have to care for the hardware.

                          Probably you can buy such things as on-demand service, I've never searched but I'm sure such service exists.

                          tomyT Offline
                          tomyT Offline
                          tomy
                          wrote on last edited by
                          #17

                          @aha_1980

                          Thank you. I suppose I'd better get back to the plan B. ;)

                          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