Standalone Qt application -- Just to be sure...
-
@kshegunov said in Standalone Qt application -- Just to be sure...:
@agarny said in Standalone Qt application -- Just to be sure...:
I get the feeling that a prerequisite to building a standalone application is furst ti build a static version of Qt. Is that really the case?
Yes.
If so, are there binaries for a static version of Qt that I could download for Windows, Linux and macOS?
Not to my knowledge. And there are also licensing implications when doing static building, i.e. you need to obtain a commercial license or release the application under GPL.
Thanks, unfortunately, for confirming my doubts.
I suppose I could live with GPL, but having to build a static version of Qt on Windows, Linux and macOS is just too much additional work for such a small project like mine.
I really wonder why Qt doesn't provide static builds. It would make things much easier for people like me who have developed a small application and who would like to provide binaries for Windows, Linux and macOS, and this without having to provide all sorts of Qt-related files. Yup, I am really puzzled...
FWIW, I just tried
windeployqt
on my application (a very simple wallpaper generator for people who use WaniKani, so the executable is relatively small (644 KB on Windows), considering that it embeds a big image). Yet, after usingwindeployqt
, I end up with more than 45 MB worth of files, which is really ridiculous for such a small application... -
Well its a premium feature and for small apps, you can just release the code and you can
have this feature for free.I agree it would be great if static version was also available but the amount of work to make it for
gcc, mingw, visual studio and macOS would be huge so the rule is that you must compile a static verison
yourself. -
@mrjj said in Standalone Qt application -- Just to be sure...:
Well its a premium feature and for small apps, you can just release the code and you can
have this feature for free.I already release the code of my application (see the link in my previous message), but I can't imagine most of my potential users (who are people learning Japanese) to be able to do anything with it...
I agree it would be great if static version was also available but the amount of work to make it for
gcc, mingw, visual studio and macOS would be huge so the rule is that you must compile a static verison
yourself.They already have everything set up to build shared versions of Qt, so wouldn't it 'only' require additional CPU time to also build those static versions?
I get the feeling that if they were to provide static binaries, more small developers might be interested in using Qt...
-
-
I already release the code of my application
Well it's not really for the end user benefit , it is to comply with the license that allows static linking of
Qt when not owning a license. -
hey already have everything set up to build shared versions of Qt, so wouldn't it 'only' require additional CPU time to also build those static versions?
Yeah, the actual building of it would just be extra hundred hours for all platforms but then after it need to be installed/tested and verified and
overall it just adds up to many hours, all to to provide easy of use for free.But I do agree that downloadable static would be helpful for attracting smaller devs but there is no money in it and hence there is no money for
such extra effort. So there is more focus on using the hours for development of new version than to supply static of all the combinations they
currently offer. I have only build static on windows and linux. But you only have to do it once as u can copy the static version.
If it was no huge, i think the community already had made some precompiled version available.
But here is also the kicker. We have ppl using 4, 4.8, 5.4 ,5.5 ,5.6, 5.7 and 5.8 so which version should have static?
All of them would be huuuuge work.So the main reason its not already include is the amount of work it is and that Qt is not charity and need income as not to perish.
-
-
@mrjj From a commercial viewpoint, I can understand Qt's position. Now, from my personal viewpoint, I get the feeling that Qt might not be what I should be using (for that small application of mine). My problem, though, is that I am not sure what other options I have besides Qt if I want to be able to target Windows, Linux and macOS. Argh! :(
-
Well I agree for a small app, its huge work to release to 3 platforms.
Also its hard to setup cross compiling in first place so most of us use
use a virtual machine for each platform. So its 3x build static version and yes
that is much work when 1 small app. If you make a living with it , it makes more sense
to setup it all to be able to produce for each platform, but I do see your point with your current project. (aww)But I could compile u a 5.7 static version and give you
and perhaps you can find someone else to produce static version for you.Note: I dont know what else you can use. Most other frame targets the mobile marked and not the Desktops.
Maybe python would do it better for such small app. ( never tested on macOS. but runs the same linux/windows) -
@mrjj Yes, I primarily develop under macOS and have VMs for Windows and Linux, and it's all working fine for my work project. Anyway, thanks for the offer, but I think I am going to leave things as they are for now (i.e. keep releasing my source code on GitHub and leave it to people to build my application themselves, if they want) and keep thinking of a possible alternative to Qt. The problem, though, is that I need my application to sit in the system tray and I also need it to have a GUI so that I can set some colours and a font. All of that can be done relatively easily using Qt, and I am not sure other platforms would make it that easy. Will see... :)
-
@agarny
Ok so u have the setup already. So would not be that huge task to make 3 statics ( when it dont error)
But its many hours compile time.
I was wondering if Google Drive allows one huge zip file. It would be possible to share a static build that way.
But it only works when Qt is installed in same place as pc where build. So its not optimal.- I need my application to sit in the system tray
Well before I landed on Qt i tested other frameworks. And when not
solely targeting the mobile area, then there were no support of native os things
like tray icons.So if you do find a framework that offer full desktop support and cross compile easy to all targets and easy deployment, please
do come back and tell the name :) -
@mrjj I just had a look at Lazarus (I used to program using Delphi / C++ Builder many years ago), but I have just seen that they don't support the system tray out of the box on Linux. Also, their IDE is really not great (compared with Qt Creator). So, that's not an option either.
As you said, I am already all set up with VMs, etc. so I might have a go at building a static version of Qt. I am just hoping that it's only going to be a matter of pressing a button and then wait for hours. Anything else might prove too much hassle for such a program.
-
@agarny
Oh, im old Delphi & Builder user and still Kylix user :)
Lazarus seems great but not as complete as Qt. It was however lovely to see VLC-(ish) again :)Its not so bad to compile a static. First google some good samples and it should be ok.
I never go around to test this script
https://gist.github.com/jakoch/ebab7ff300e76257a1bd
I was told just alter the download path it would do all for me. :)
But I wanted to learn.I think i spend 1 hour reading docs then just compiled it.
When there is no webkit classes involved its much easier.
If mac is your pref. Os, then maybe try there first just to see.
( i assume its linux like. Sorry never used macOS so it might be ok easy) -
Hi,
To add to @mrjj, "just adding" the static builds doubles the number of provided platforms which includes 3 different compilers only for the Windows version, then you add in Android which is available on the other desktop platforms as well and then iOS. And with all of that we don't take into account architecture.
All the provided packages are tested by people because not everything can be automatically tested.
The infrastructure building the package is the same that is already building Qt several times a day to incorporate all the validated submissions.That said for the size of the dependencies of your application, Qt 5.8 comes with a new configuration system that will make it easier to tune so you can include only what you need in your build.
-
@mrjj said in Standalone Qt application -- Just to be sure...:
Its not so bad to compile a static. First google some good samples and it should be ok.
I never go around to test this script
https://gist.github.com/jakoch/ebab7ff300e76257a1bd
I was told just alter the download path it would do all for me. :)I just had a quick look and it relies on MinGW while I use MSVC 2015. Still, it ought to get me started.
@SGaist said in Standalone Qt application -- Just to be sure...:
To add to @mrjj, "just adding" the static builds doubles the number of provided platforms which includes 3 different compilers only for the Windows version, then you add in Android which is available on the other desktop platforms as well and then iOS. And with all of that we don't take into account architecture.
All the provided packages are tested by people because not everything can be automatically tested.
The infrastructure building the package is the same that is already building Qt several times a day to incorporate all the validated submissions.That is all fine, it's just that I mentioned at some point: it doesn't make it easy for people who want to develop and distribute small applications.
That said for the size of the dependencies of your application, Qt 5.8 comes with a new configuration system that will make it easier to tune so you can include only what you need in your build.
Interesting, would you mind telling us more about this? Maybe a link or something?
-
@SGaist Ignore my request, I think I have found what I need: https://blog.qt.io/blog/2016/09/05/qt-5-8-alpha-released/ and http://blog.qt.io/blog/2016/08/18/introducing-the-qt-lite-project-qt-for-any-platform-any-thing-any-size/.
-
@agarny said in Standalone Qt application -- Just to be sure...:
I think I have found what I need
Yes, this is it.
-
FWIW, I have managed to build a static version of Qt 5.6.2 LTS on Windows, Linux and macOS. It was probably eased by the fact that I am already building QtWebKit (for another project, but I don't need it for this one). Anyway, and just in case, here is how I am building Qt 5.6.2 LTS:
Prerequisites:
- Download and extract Qt 5.6.2 from https://download.qt.io/official_releases/qt/5.6/5.6.2/single/.
- Windows: edit [Qt]/qtbase/mkspecs/common/msvc-desktop.conf by replacing:
QMAKE_CFLAGS_RELEASE = -O2 -MD QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MD -Zi QMAKE_CFLAGS_DEBUG = -Zi -MDd
with:
QMAKE_CFLAGS_RELEASE = -O2 -MT QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MT -Zi QMAKE_CFLAGS_DEBUG = -Zi -MTd
- Linux: make sure that FontConfig is installed (
libfontconfig1-dev
package on Ubuntu). - macOS: apply the patch at https://code.qt.io/cgit/qt/qtconnectivity.git/commit/?h=5.7.1&id=462323dba4f963844e8c9911da27a0d21e4abf43.
Windows:
CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\vcvarsx86_amd64.bat" configure -prefix C:\Qt\Static -opensource -confirm-license -release -static -nomake libs -nomake tools -nomake examples jom jom install
Linux:
./configure -prefix /opt/Qt/Static -opensource -confirm-license -release -static -nomake libs -nomake tools -nomake examples -qt-xcb make -j 2 sudo make install
macOS:
./configure -prefix /Applications/Qt/Static -opensource -confirm-license -release -static -nomake libs -nomake tools -nomake examples make -j 4 make install
So, now, I am able to statically build my small application, which is perfect. So, thanks all for 'forcing' me into statically building Qt.
-
Thank you for the write up. That will surely come in handy.
Good luck with the app. -
@agarny said in Standalone Qt application -- Just to be sure...:
Hi,
I never had the need to do it until now, but from googling around (e.g. here), I get the feeling that a prerequisite to building a standalone application is furst ti build a static version of Qt. Is that really the case? If so, are there binaries for a static version of Qt that I could download for Windows, Linux and macOS?
Cheers, Alan.
It depends on what you mean by 'stand alone'. I consider stand alone to mean something that you can run without installing the application or other application dependencies. You don't need a static build to do this. If you want to have one executable file then this is when you need a static build.
The application size (sum of size of all required dll's or size of executable) can be large. In your case (45 mb) it sounds like you included the webkit icu dll's. If you build your own version of qt from the sources and exclude webkit you won't have these dependencies and should end up with something around 17 mb.
For a stand alone application (using my definition which means it doesn't need to be installed) you should not be using Visual Studio. You will likely need to install the VCRT distributable on every system that you run the program on. The user will end up with an error message when running on a system without the proper VCRT installed. If there is a way to change this behavior in Visual Studio I would like to know otherwise using MinGW is a better option.
-
@Rondog I don't actually use QtWebKit in this small application (I have edited my previous comment accordingly). I just meant that because I need to build QtWebKit for another project, I already have some other prerequisites installed (e.g. Perl, Python, Ruby, etc. on Windows).
Regarding a standalone application, I indeed meant that I am after one executable file and nothing else (i.e. no shared libraries having to be shipped with my application). This is what I have achieved and my application is ~15.4 MB on Windows, for example.
Finally, with regards to Visual Studio, it's actually all fine since Qt was built using
-MT
and not-MD
. As a result, all my application needs are systems DLLs: -
Just one thing to take into consideration when using the Visual Studio static runtime. When a new release is done, you're application won't benefit from it. So if there's a security issue found you should provide a new version of your application.