PDA

View Full Version : Newbie needs help building a static release program



actor39
16th April 2020, 22:00
Hi! I have tried twice to start this thread, but maybe my post was too long. In a nutshell, I am a Greenhorn and need help building a static opensource program I can take to my other computer. If this post makes it to the forum, I will submit another one explaining my problems in full.
OK! I made it! Here's the problem: I began learning how to use Qt about 3 weeks ago, and am a fully self taught hobbyist. I have coded a nice program using Qt Creator, and it works fine. I use v. 5.14.1 with MinGW v. 7.3.0. But now I want to take it to my other computer. So I think I need to do a static build of Qt, and use it to statically compile my program. I tried to follow the instructions I found here: https://wiki.qt.io/Building_a_static_Qt_for_Windows_using_MinGW. I modified the script to use this source package: qt-everywhere-src-5.14.1.zip, and the building ended with an error, which I unfortunately did not document. But I have lots of stuff in my C:\Qt\Static older, so I tried anyway, but it doesn't integrate with Qt Creator like the instructions say it should. The instructions seemed to suggest I use a source file named qt-everywhere-opensource-src-5.14.1.7z, but I couldn't find one by that name. So I am wondering how to proceed. I am tempted to just attempt to re-run the static installation script and see if the error persists. But should I remove the Static folder before doing that? Is there a recommended way to remove it? I really like Qt so far, and I hope that I can overcome these problems because I would like to do lots of programs for my own use, using Qt. So I will appreciate any assistance you can provide! Thank you!!!

d_stranz
17th April 2020, 01:14
You do not need to build a static distribution of Qt in order to create programs that can be deployed to PCs without Qt installed. You simply need to deploy whatever shared libraries (DLL on Windoze, .so on linux) and other resources are required to run the program. It is nowhere near as hard as you are trying to make it.

Read the Qt documentation on deployment (https://doc.qt.io/qt-5/deployment.html) and pay special attention to the directory structure needed for things like plugins, database drivers, etc. if you use them.

ChrisW67
17th April 2020, 01:26
Welcome actor39

You do not actually need a static Qt build in order to deploy your application to another machine. The only thing a static build will get you, apart from the effort of building it and limitations it imposes, is a smaller number of files to deploy (maybe as small as one).

Have you been through this page? https://doc.qt.io/qt-5/windows-deployment.html


Addendum:
D'oh! Should have previewed before submitting.

actor39
17th April 2020, 14:43
Thanks to d_stranz and ChrisW67 for your response. Since I am a newbie, I think I will pursue both avenues to Windows deployment, just for the experience and learning opportunity. Since I am so far along this static path, I want to spend a few more days trying it before branching off to the shared libraries process.
Last night I had another look at the PS script, and I found this reference:
https://forum.qt.io/topic/88891/problems-creating-static-qt-was-5-10-1-broke-one-of-my-builds
I took the suggestion for modifying the PS script and tried again. This time no error messages have been posted, but the script "hangs". The last line I see is:
Info: creating stash file C:\Qt\Static\src\qt-everywhere-src-5.14.1\.qmake.stash
While investigating this problem, I found this reference:
https://forum.qt.io/topic/104238/configure-qt-for-webassembly-seems-to-be-stuck-at-info-creating-stash-file-forever
(which I do not understand), and this reference:
https://stackoverflow.com/questions/41887821/building-qt-5-8-from-source-configure-unknown-command-line-option-c11
which seems to suggest that in the call to qmake, the "-c++11" flag is at fault. But I have no idea how to "make" the Qt static build except to use the PS script. I suspect that there are some very minor inaccuracies in the PS script due to some system upgrades which have taken place since it was written. In fact, this post suggests that I have found and corrected some of these already. But I have no idea how to produce a 100% correct PS script that will do the static install for me. As mentioned, any assistance will be greatly appreciated!

d_stranz
20th April 2020, 21:26
Apparently you really like doing things in the most difficult way possible. Virtually no one does static deployments of Qt apps. Bulding a static Qt distribution just isn't worth the days of pain. It is far too easy to just bundle the required DLLs, which for a typical Windows GUI app are only 4: Qt5Core, Qt5Gui, Qt5Widgets, and qwindows, and probably the same on linux.

And as ChrisW67 says, even if you do get a static build, it may not support what your app needs. Some Qt things are only supported with dynamic libraries and AFAIK you can't mix static and dynamic libraries, at least not on Windows.