PDA

View Full Version : Deploying Qt5 app requires lots of DLL's



wayfaerer
20th November 2012, 00:40
I'm porting a relatively simple program from Qt4 to Qt5. I have everything working, but the number and size of the DLL's that are now required to be in my application folder have increased. Whereas before I only needed to put QtCore4.dll and QtGui4.dll into my application folder, now I need those (QtCore5.dll and QtGui5.dll) plus the following:

icudt49.dll
icuin49.dll
icuuc49.dll
libEGL.dll
libGLESv2.dll
QtMultimedia5.dll
QtNetwork5.dll
QtWidgets5.dll

Of those, the only ones that make sense to me are QtMultimedia (I am usng QSound which was in QtGui before, but now is in QtMultimedia), and QtWidgets. I don't use QtNetwork that I know of, and tried adding "QT -= network" to my .pro file, but my executable still complained about missing QtNetwork5.dll if I removed it.

I have been trying to read about what could be the cause of the other extra dependencies. For example, I have seen that "ANGLE" is enabled by default (http://qt-project.org/doc/qt-5.0/deployment-windows.html) but I do not use OpenGL or QML and I don't understand how to disable it. I have also read about ICU, but I don't need it (that I know of) so I find it strange that there are 20 MB worth of dll's that seem to be required to run my executable.

I'd appreciate some feedback on whether or not it is possible to reduce these dependencies. Thanks!

By the way, I'm using Windows 7 and Qt5 beta 2.

anda_skoa
20th November 2012, 10:06
Lets see.

No idea why you got the network dependency, maybe dragged in my QtMultimedia?

OpenGL capabilities are available in QtGui but I believe you can configure Qt to not include that.

As for ICU, it is now used on all platforms for proper localization support, e.g. locale dependent formatting of dates.
Most applications will need translation/localizations so I think this is a dependency of QtCore. Might still be possible to configure Qt without if your applications is never used with a different language or in a different locale.

Cheers,
_

wayfaerer
20th November 2012, 11:09
When you say that I could maybe configure Qt without OpenGL, do you mean that I would have to build Qt myself? Or is there something I can put in my .pro file?

Well, the OpenGL DLL's are only 1 MB, so it's not that frustrating, but the ICU DLL's are about 20 MB's, which triples the size of my whole application for features I don't want.

There has been much talk about QtWebkit. I wonder if that is what introduces the ICU dependencies. If so, to remove QtWebkit, would I just need to rebuild the Qt library with -no-webkit? I also see a configuration option -no-opengl.

anda_skoa
20th November 2012, 18:11
When you say that I could maybe configure Qt without OpenGL, do you mean that I would have to build Qt myself?

Yes, that is what I meant. Qt can be highly customized, see e.g. http://doc.qt.digia.com/4.7.1/fine-tuning-features.html



but the ICU DLL's are about 20 MB's
I believe that is because of the localization data included in the lib. Unfortunately Windows doesn't ship any ICU itself (unlike OSX or Linux where Qt can use the system ICU).


which triples the size of my whole application for features I don't want.
It might be possible to remove localization features, there is QT_NO_TRANSLATION in some files which usually means that is a deactivatable feature.



There has been much talk about QtWebkit. I wonder if that is what introduces the ICU dependencies.

Unlikely, translation and localization support is a Qt core feature, not related to QtWebKit at all.

Cheers,
_

Gokulnathvc
21st November 2012, 06:51
Try with Qt Static build.

1. Install QtSDK (2009.05)

2. Open your mkspecswin32-g++qmake.conf file (located in C:\Qt\2009.05\qt\mkspecs\win32-g++\qmake.conf) in an editor like notepad.

3. Find the line that starts with "QMAKE_LFLAGS = -enable-stdcall-fixup..." and ddd the phrase "-static" (without quotes) after the "=" sign and before the "-enable..." phrase, so it looks like:
QMAKE_LFLAGS = -static -enable-stdcall...

4. Save and close this file.

5. Set your environment variables. Right-click Computer >> Properties >> Advanced System Settings >> Click the "Environment Variables..." button.

6. Under "User variables," make sure QTDIR is set to your Qt path (C:\Qt\2009.05\qt). Make sure QMAKESPEC is set to win32-g++.

7. Under "System variables," edit the one called "Path." Add a semicolon ( ; ) to the end, and add the following:
C:\Qt\2009.05\mingw\lib;C:\Qt\2009.05\mingw\bin;C: \Qt\2009.05\qt\bin

8. When finished, relog or reboot.

9. Open a command prompt.

10. Change to your Qt directory by entering: cd C:\Qt\2009.05\qt

11. Enter the following: configure -static -no-phonon -no-phonon-backend -release -no-exceptions

12. When it asks which edition you want to use, enter "o" for open source.

13. When it asks you to accept the terms of the license, enter "y" for yes. This will take around maybe 10 minutes to complete.

14. When that finishes, enter the following: mingw32-make sub-src (or) nmake sub-src

15. Go out to dinner, this will take a while (took between 1-2 hours for me).

16. When this finishes, open your project in the Qt Creator.

17. Double-click the project (.pro) file to open it in edit mode.

18. Add the following line: CONFIG += static

19. qmake Hello.pro
nmake release (or) mingw32-make release

20. Navigate to your release directory and voila! Your standalone executable should be there.

wayfaerer
21st November 2012, 12:51
That looks very helpful. Thanks! However I don't want to build statically due to licensing issues. Is the process mostly the same for building dynamically?

Gokulnathvc
22nd November 2012, 05:12
For dynamic building, you need to use exe bundler or the dll's needed. It will be huge. Also you need to copy all those dll's and files to the system that needs this software. Better go for Static building with Open source license. Just a single exe that will do all your needs. Best of luck.

wysota
22nd November 2012, 05:26
For dynamic building, you need to use exe bundler or the dll's needed. It will be huge. Also you need to copy all those dll's and files to the system that needs this software. Better go for Static building with Open source license. Just a single exe that will do all your needs. Best of luck.

Building statically will not help much here. It would if you had static versions of all the required libraries in the first place (like all the ICU libraries) and obtaining those requires additional work compared to just rebuilding Qt.

ferdna
24th January 2013, 00:14
read:

http://qt-project.org/doc/qt-5.0/qtdoc/deployment-windows.html

munkeino@hotmail.com
5th March 2013, 07:50
Hi,

I'm also wondering the same thing. I've now read the deployment manuals but could not find any clues how to get rid of unnecessary libraries. Nearly everywhere this subject is mentioned like "If you use ANGLE..." or "If you are using ICU...", but I can't find anywhere articles how to exclude those dependencies from my project. I don't want to use ANGLE (Qt5Opengl.dll) or Qt5sql.dll or Qt5Multimedia.dll.

How to disable/exclude those from my project? Thanks.

--
pedro

wysota
5th March 2013, 10:08
How to disable/exclude those from my project?
Don't use libraries that have these components as their dependencies. If you build against only QtCore, your application will not depend on ANGLE. But if you use QtGui, it will.

munkeino@hotmail.com
5th March 2013, 12:08
I looked my .exe with Dependency Walker. Seems like Qt libraries are indeed of need of many other libraries.

For example I have to use QtWebKit in my project, but I don't use any sql, multimedia (sound etc.) or qml at all. But Dependency Walker shows me that Qt5WebKit.dll is dependent of Qt5Quick.dll, Qt5Multimedia.dll, Qt5Qml.dll and Qt5Sql.dll. This totally sucks.

Also when I include QtWebkitwidgets.dll it want's me to add also Qt5Opengl.dll which wants me to include Qt5Printsupport.dll along my executable. I don't use any opengl or print functionalities at all.

So does this mean that I have to surrender and copy all those, I think unnecessary, .dll files to my executable folder because some other .dll files depend on them? Yes those files are not so big but there are so many of them. Also for example Qt5Opengl.dll and Qt5Printsupport.dll files in my application folder looks funny because my application shows only a web page in a dialog.

wysota
5th March 2013, 12:25
For example I have to use QtWebKit in my project, but I don't use any sql, multimedia (sound etc.) or qml at all. But Dependency Walker shows me that Qt5WebKit.dll is dependent of Qt5Quick.dll, Qt5Multimedia.dll, Qt5Qml.dll and Qt5Sql.dll. This totally sucks.
Qt5Webkit is a library providing WebKit for QtQuick. You don't want that.


Also when I include QtWebkitwidgets.dll it want's me to add also Qt5Opengl.dll which wants me to include Qt5Printsupport.dll along my executable. I don't use any opengl or print functionalities at all.
You don't but the browser does (for WebGL and printing). If you don't like it, you can always build a custom configuration of WebKit that will not require those.


So does this mean that I have to surrender and copy all those, I think unnecessary, .dll files to my executable folder because some other .dll files depend on them?
In theory if you are sure that their code will never be called (e.g. the user will not request WebKit to print anything) you could substitute them with a stub library to reduce the overall size.

If you are really interested and eagar to minimize dependencies then build a custom version of Qt. If you disable printing and OpenGL altogether during compilation, you will not have to deploy them. If you don't want to spend your time on reconfiguring and rebuilding Qt then it's easiest to just deploy those libraries you don't need. You can use UPX or a similar tool to reduce their size.

munkeino@hotmail.com
5th March 2013, 14:05
Qt5Webkit is a library providing WebKit for QtQuick. You don't want that.

Hmm... I don't have "Qt += webkit" module at all on my project. For some reason it still wants that.

I'm using both QWebView and QWebPage. Docs (http://qt-project.org/doc/qt-5.0/qtwebkit/qtwebkit-module.html) says that they are indeed underneath webkitwidgets. But when I go inside source code of QWebView or QWebPage they both seems to include QtWebKit in their code. Maybe that is the reason my application wants also QtWebKit. Dependency Walker shows that Qt5Webkitwidgets.dll has dependecies to QtWebKit.dll.

I also noticed that apparently using QWebSettings needs Qt5WebKit.dll.

wysota
5th March 2013, 14:55
Hmm... I don't have "Qt += webkit" module at all on my project. For some reason it still wants that.
It seems webkitwidgets requires it. Unfortunately webkit pulls in quick and sql.

Maybe an alternative is to not use WebKit at all? Isn't what QTextBrowser supports enough for you?

Cataclismo
2nd January 2015, 17:29
Try with Qt Static build.

1. Install QtSDK (2009.05)

2. Open your mkspecswin32-g++qmake.conf file (located in C:\Qt\2009.05\qt\mkspecs\win32-g++\qmake.conf) in an editor like notepad.

3. Find the line that starts with "QMAKE_LFLAGS = -enable-stdcall-fixup..." and ddd the phrase "-static" (without quotes) after the "=" sign and before the "-enable..." phrase, so it looks like:
QMAKE_LFLAGS = -static -enable-stdcall...

4. Save and close this file.

5. Set your environment variables. Right-click Computer >> Properties >> Advanced System Settings >> Click the "Environment Variables..." button.

6. Under "User variables," make sure QTDIR is set to your Qt path (C:\Qt\2009.05\qt). Make sure QMAKESPEC is set to win32-g++.

7. Under "System variables," edit the one called "Path." Add a semicolon ( ; ) to the end, and add the following:
C:\Qt\2009.05\mingw\lib;C:\Qt\2009.05\mingw\bin;C: \Qt\2009.05\qt\bin

8. When finished, relog or reboot.

9. Open a command prompt.

10. Change to your Qt directory by entering: cd C:\Qt\2009.05\qt

11. Enter the following: configure -static -no-phonon -no-phonon-backend -release -no-exceptions

12. When it asks which edition you want to use, enter "o" for open source.

13. When it asks you to accept the terms of the license, enter "y" for yes. This will take around maybe 10 minutes to complete.

14. When that finishes, enter the following: mingw32-make sub-src (or) nmake sub-src

15. Go out to dinner, this will take a while (took between 1-2 hours for me).

16. When this finishes, open your project in the Qt Creator.

17. Double-click the project (.pro) file to open it in edit mode.

18. Add the following line: CONFIG += static

19. qmake Hello.pro
nmake release (or) mingw32-make release

20. Navigate to your release directory and voila! Your standalone executable should be there.

It's working only with SDK?
I am using MinGW 4.9 and Qt 5.4 and I can't make step 11. It's saying that "configure" is not a recognized command.
I edited qmake.conf and I added the flag. Also, in my project I edited .pro file and I added the required line. I built it successfully. When I run it it's working, but on other computers it's not starting at all. No errors.

So what I have to do? I have to use SDK? Or what are the steps for my environment?

ferdna
2nd January 2015, 17:43
perhaps you are doing it on the wrong directory. there is one configure.exe in your qt root dir and another one in your qtbase.

Cataclismo
2nd January 2015, 17:46
perhaps you are doing it on the wrong directory. there is one configure.exe in your qt root dir and another one in your qtbase.

No, is not. I've searched for it.
But I said before. Maybe I need SDK, but I don't know for sure. That's why I asked Q_Q

d_stranz
2nd January 2015, 18:44
Are you sure you have a source code distribution of Qt? In my copy of Qt 5.2, there is a "configure.exe" and a "configure.bat" under the qtbase directory. If the EXE does not exist, then the BAT file will bootstrap it from source. You will need a perl installation in order to do that.

ferdna
2nd January 2015, 18:55
my suggestion is that you open another thread so they can help you with your problem... this is a totally different issue.