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. How do I get the QT application I've made to run on Windows, Linux and Android operating systems?
QtWS25 Last Chance

How do I get the QT application I've made to run on Windows, Linux and Android operating systems?

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 4 Posters 3.0k Views
  • 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.
  • serkan_trS Offline
    serkan_trS Offline
    serkan_tr
    wrote on last edited by
    #1

    Hi,
    I am writing an application via QT. I am using Cmake, C++ and QML in my application. After compiling this application, it works when you transfer the build folder of the application to a different computer in the same operating system. (I'm doing windeploy). But it doesn't work when I put the same application on a different operating system. My goal is for my system to work regardless of the environment I'm compiling. I want the compilation process to run in any environment, no matter what environment I do it in Windows Linux. Also, when trying to run on the same operating system, I move the build folder to the other computer, isn't it enough to just throw the executable file instead?
    Can this be done or not done?

    Chris KawaC 1 Reply Last reply
    0
    • serkan_trS serkan_tr

      Hi,
      I am writing an application via QT. I am using Cmake, C++ and QML in my application. After compiling this application, it works when you transfer the build folder of the application to a different computer in the same operating system. (I'm doing windeploy). But it doesn't work when I put the same application on a different operating system. My goal is for my system to work regardless of the environment I'm compiling. I want the compilation process to run in any environment, no matter what environment I do it in Windows Linux. Also, when trying to run on the same operating system, I move the build folder to the other computer, isn't it enough to just throw the executable file instead?
      Can this be done or not done?

      Chris KawaC Online
      Chris KawaC Online
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @serkan_tr said:

      Can this be done?

      No. Those operating systems have completely different formats of executables. You can't have one build work on all of them.
      There are also platform differences in APIs. Imagine somewhere deep in its implementation Qt calls OpenFile on Windows. How would that work on Linux or Android, which don't have that function?

      You have to recompile your app for each platform you want to support, using a build of any libraries (including Qt) use use built for that specific platform.

      serkan_trS 1 Reply Last reply
      3
      • Chris KawaC Chris Kawa

        @serkan_tr said:

        Can this be done?

        No. Those operating systems have completely different formats of executables. You can't have one build work on all of them.
        There are also platform differences in APIs. Imagine somewhere deep in its implementation Qt calls OpenFile on Windows. How would that work on Linux or Android, which don't have that function?

        You have to recompile your app for each platform you want to support, using a build of any libraries (including Qt) use use built for that specific platform.

        serkan_trS Offline
        serkan_trS Offline
        serkan_tr
        wrote on last edited by
        #3

        @Chris-Kawa So instead of moving the folder where I compiled the file, can I create a file that only works in the windows environment? For example, command_setup.exe. There are many packages etc. in the file that I constantly compile, I want them all to be combined into one executable file.

        For example, there is a drekt .exe file of the QGroundControl application, and we can also download the file directly from the git@github.com:mavlink/qgroundcontrol.git page and build it over QT.When we compile via QT, only one file, QGC.exe, is created as they do.

        Chris KawaC 1 Reply Last reply
        0
        • serkan_trS serkan_tr

          @Chris-Kawa So instead of moving the folder where I compiled the file, can I create a file that only works in the windows environment? For example, command_setup.exe. There are many packages etc. in the file that I constantly compile, I want them all to be combined into one executable file.

          For example, there is a drekt .exe file of the QGroundControl application, and we can also download the file directly from the git@github.com:mavlink/qgroundcontrol.git page and build it over QT.When we compile via QT, only one file, QGC.exe, is created as they do.

          Chris KawaC Online
          Chris KawaC Online
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by Chris Kawa
          #4

          @serkan_tr Again, no. .exe files are Windows specific. You can't run them on Linux, Mac or Android.
          You have to produce an executable for each platform separately. By executable I mean a binary file in platform specific format, not .exe file. Those are just for Windows. There is no one thing (setup or anything else) that can run on all of them.

          When we compile via QT (...)

          Qt is not a compiler. It's a C++ library. You compile the program via platform specific compiler e.g. MSVC or MinGW on Windows, GCC on Linux, Clang on Mac etc.

          only one file, QGC.exe, is created as they do

          Only one file for Windows is created when you compile it with toolkit targeting Windows. When you switch to another toolkit that compiles for different platform it will produce a different binary.

          serkan_trS 1 Reply Last reply
          1
          • Chris KawaC Chris Kawa

            @serkan_tr Again, no. .exe files are Windows specific. You can't run them on Linux, Mac or Android.
            You have to produce an executable for each platform separately. By executable I mean a binary file in platform specific format, not .exe file. Those are just for Windows. There is no one thing (setup or anything else) that can run on all of them.

            When we compile via QT (...)

            Qt is not a compiler. It's a C++ library. You compile the program via platform specific compiler e.g. MSVC or MinGW on Windows, GCC on Linux, Clang on Mac etc.

            only one file, QGC.exe, is created as they do

            Only one file for Windows is created when you compile it with toolkit targeting Windows. When you switch to another toolkit that compiles for different platform it will produce a different binary.

            serkan_trS Offline
            serkan_trS Offline
            serkan_tr
            wrote on last edited by
            #5

            @Chris-Kawa What I mean is actually for windows operating system, now I can run the application on other windows installed device by making windeployqt the build file that comes out when I compile with QT creator. My question is, can I create a .exe file directly instead of this ild folder?
            i just want to share a file instead of a whole folder (windows on two computers)

            Chris KawaC 1 Reply Last reply
            0
            • serkan_trS serkan_tr

              @Chris-Kawa What I mean is actually for windows operating system, now I can run the application on other windows installed device by making windeployqt the build file that comes out when I compile with QT creator. My question is, can I create a .exe file directly instead of this ild folder?
              i just want to share a file instead of a whole folder (windows on two computers)

              Chris KawaC Online
              Chris KawaC Online
              Chris Kawa
              Lifetime Qt Champion
              wrote on last edited by Chris Kawa
              #6

              @serkan_tr There are two options for that.
              You can use static linking (you'll need to compile Qt yourself to produce static link libraries for that) and place all your assets in the resource file that will get embedded in the executable. This will produce one fat exe file, but keep in mind static linking comes with license restrictions. You'll have to provide source code of your app.
              The other option is creating an installer for your app. It's a separate project that creates a single executable setup that extracts all the files of your app to a directory specified by user. See Qt Installer Framework.

              serkan_trS S 2 Replies Last reply
              3
              • Chris KawaC Chris Kawa

                @serkan_tr There are two options for that.
                You can use static linking (you'll need to compile Qt yourself to produce static link libraries for that) and place all your assets in the resource file that will get embedded in the executable. This will produce one fat exe file, but keep in mind static linking comes with license restrictions. You'll have to provide source code of your app.
                The other option is creating an installer for your app. It's a separate project that creates a single executable setup that extracts all the files of your app to a directory specified by user. See Qt Installer Framework.

                serkan_trS Offline
                serkan_trS Offline
                serkan_tr
                wrote on last edited by
                #7

                @Chris-Kawa
                Thank you

                1 Reply Last reply
                0
                • serkan_trS serkan_tr has marked this topic as solved on
                • Chris KawaC Chris Kawa

                  @serkan_tr There are two options for that.
                  You can use static linking (you'll need to compile Qt yourself to produce static link libraries for that) and place all your assets in the resource file that will get embedded in the executable. This will produce one fat exe file, but keep in mind static linking comes with license restrictions. You'll have to provide source code of your app.
                  The other option is creating an installer for your app. It's a separate project that creates a single executable setup that extracts all the files of your app to a directory specified by user. See Qt Installer Framework.

                  S Offline
                  S Offline
                  SimonSchroeder
                  wrote on last edited by
                  #8

                  @Chris-Kawa said in How do I get the QT application I've made to run on Windows, Linux and Android operating systems?:

                  You'll have to provide source code of your app.

                  This is not true. You need to provide a way for the user to relink. You could just provide the objects files instead of the source code. But, there are additional restrictions to consider.

                  I don't know of any other suitable solution for Windows than what has already been described. However, for Linux there exists AppImage which works together with linuxdeploy and linuxdeployqt. There are similar other tools which all basically are disk images which mount automatically and execute the default program. For the user it looks like a single file. For macOS there is always the .app folder which behaves like the program itself. So, macOS is also no problem. I don't know about Android, though.

                  SGaistS 1 Reply Last reply
                  2
                  • S SimonSchroeder

                    @Chris-Kawa said in How do I get the QT application I've made to run on Windows, Linux and Android operating systems?:

                    You'll have to provide source code of your app.

                    This is not true. You need to provide a way for the user to relink. You could just provide the objects files instead of the source code. But, there are additional restrictions to consider.

                    I don't know of any other suitable solution for Windows than what has already been described. However, for Linux there exists AppImage which works together with linuxdeploy and linuxdeployqt. There are similar other tools which all basically are disk images which mount automatically and execute the default program. For the user it looks like a single file. For macOS there is always the .app folder which behaves like the program itself. So, macOS is also no problem. I don't know about Android, though.

                    SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @SimonSchroeder if using GPL, then yes, people can request the sources of the application and the author has to provide them. For LGPL, you can keep your code private but you have to provide any and all changes you may have applied to your LGPL dependencies. This is beside the fact that people shall be able to replace these LGPL dependencies with their own build which make static builds pretty cumbersome to abide to (not impossible though).

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    3

                    • Login

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