How do I get the QT application I've made to run on Windows, Linux and Android operating systems?
-
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? -
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?@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_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.
@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-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.
@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_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.
@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-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)@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_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.@Chris-Kawa
Thank you -
S serkan_tr has marked this topic as solved on
-
@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.@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.
-
@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.
@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).