PDA

View Full Version : Static Build Issue on QT 5.15.0



rajganesh
6th October 2020, 08:35
Hi Team,

We are building QT for static build. We have a licensed perpetual software but our support got expired recently.

We have followed below link for configuring QT for static.
https://wiki.qt.io/Building_a_static_Qt_for_Windows_using_MinGW

But we are getting attached error
Error 1:
"mimetypes\qmimeprovider.cpp:632:30: error: 'mimetype_database' was not declared in this scope
Q_STATIC_ASSERT_X(sizeof(mimetype_database), "Bundled MIME database is empty");"
Error 2:
"mimetypes\qmimeprovider.cpp:633:52: error: 'MimeTypeDatabaseOriginalSize' was not declared in this scope
Q_STATIC_ASSERT_X(sizeof(mimetype_database) <= MimeTypeDatabaseOriginalSize,"

Please help us out on this issue ASAP.

Thanks,
raj

QTom
10th February 2021, 15:06
Hi there!

I also got this error just now when trying to compile a Windows 32-bit static build of Qt 5.15.2 using MinGW.
Sorry to see there is no solution for this issue posted here yet. :crying: Please @rajganesh report if you
have found a solution. I'm unable to deploy dynamic Qt because there will be some strange runtime linking errors.
Static is much more reliable and care free to deploy and I have always used static builds successfully with Qt 3 and Qt 4.

Thanks, Tom

d_stranz
10th February 2021, 17:52
I'm unable to deploy dynamic Qt because there will be some strange runtime linking errors.

Only if you make mistakes in your compilation, linking, and deployment. I have been delivering 32- and 64-bit Qt-based, dynamically-linked apps for over 10 years without problems.

If your build configuration is wrong and you are compiling and linking against a different version of Qt and/or MSVC than you are using for deployment or you are mixing and matching Debug and Release DLLs, then you are very likely to get DLL errors. If everything is consistent, then there should be no runtime problems.

QTom
15th February 2021, 07:50
My problem was simple. In the build process there was the call to cmd /c mimetypes\mime\generate.bat which generates the qmimeprovider_database.cpp
That failed because the PowerShell ExecutionPolicy was restricting executions. That bat script could be manually run for both debug and release but then there was other scripts that failed. So I temporarily disabled the PowerShell restrictions and the compile succeeded.

Added after 22 minutes:

Dynamic vs static... Yes previously I have sometimes copied the .dll files from the Qt library together with the dynamic Qt build and it has worked. For some reason now with Qt5 when I did not have a static library and quickly I needed to run my program on another machine this did not work any more. Anyway, the library is updated so frequently that the odds that two Qt programs will have the same dll versions is getting so small that a static build will occupy less space on the disk. It is crazy thinking that a simple win32 hello world static Qt5 application takes 18 MB and needs more that 10 floppy disks to be distributed. A few years ago I was making a much more advanced win32 applications with same look & feel, using Borland C++ Builder, and those would take 100kb disk space and you could fit 10 such programs on a floppy disk.

d_stranz
15th February 2021, 16:40
Yes previously I have sometimes copied the .dll files from the Qt library together with the dynamic Qt build and it has worked.

Are you aware that Qt comes with a deployment tool (https://doc.qt.io/qt-5/windows-deployment.html) that identifies the DLLs required for a dynamically-linked distribution?


with Qt5 ... this did not work any more.

Because in Qt5, the dependence on the underlying OS and GUI system was refactored, which resulted in a different directory structure required for the installation of the executable. An install now requires a "platforms" subdirectory under the directory for the executable that contains the platform-specific DLL, in this case "qwindows.dll". If you have other plugins, like database drivers, these have to go into a "plugins" subdirectory, and so forth.

From what I read of Qt6, more refactoring has occurred with respect to the platform's graphics system, but i do not know if this has changed the deployment requirements. Likely there are more platform-specific DLLs required.


a simple win32 hello world static Qt5 application takes 18 MB

A dynamically-linked Qt5 Windows app takes the same. Qt5Core, Qt5Gui, Qt5Widgets, and qwindows DLLs add up to 18 MB. Apparently your linker drags in the entire static library regardless of how much of it your app actually uses.


and needs more that 10 floppy disks to be distributed.

Ummm, there are these new shiny things called "CDs" and "DVDs" that companies use to distribute software now. Some of them are even using this invisible thing called "the Internet", which sort of works like Compuserve, except without wires or a 1200 baud modem. You should look into it.