views:

108

answers:

2

Hi all,

I've recently been looking at Qt, and yes I should have started a long time ago... But the issue has come up that the prebuilt or self compiled .dlls, QtCore4.dll, QtGui4.dll, etc., are quite large.

Since I must stay within the LGPL, is there a correct way to only link in what I need into the QtCore4.dll and QtGui4.dll files so that my application can use it? It'd really be nice to have a single Qt.dll file too, but not necessary.

I've already tried a few things: using their configure.exe program to remove some unneeded features. It shrank some compared to the default SDK install, but not much. I've also tried to start a brand new .dll project and add the .cpp files manually as I need them. But VS2008 complained about the source.

Thanks.

A: 

You could rebuild Qt to generate static libraries (no DLLs). This way, you'll not have DLLs anymore, and the linker will link only the used functions, not everything. You could check the Qt documentation about how to rebuild Qt as static libraries.

Cătălin Pitiș
You should note that he is using LGPL and explicitly want (as LGPL states) to use DLL. The only correct way is to use a custom DLL-s not static libraries.
Ross
@Ross: I don't understand what does LGPL have anythuing to do with rebuild. Nor why it is so necessary to have Qt as DLL. If the difference in size is significant with a static library, I would consider this solution and accept not using Qt as DLL. Not to mention that it would take less time to rebuild as static library than setting up a custom DLL. Isn't choosing the right solution making compromises, when necessary?
Cătălin Pitiș
What compromises? LGPL clearly states that you can't use static library, only DLL. Qt is available as commercial license also, but OP states that he must stay within the LGPL.
Ross
A: 

I'll try to explain you how to do it with Qt Creator. First of all, in the Build menu, make sure that your build target is set to Release. This way, you will be able to use only the non-debugging .dlls and that will reduce the size of the contents you'll need. For example, QtCore4.dll (non-debugging) is 2478 KB and QtCored4.dll (debugging) is 30493 KB. This would be a start.

The other solutions I'd see is the following:

In the .pro file of your project, add the following line:

QT -= network xml

This would remove the dependencies to QtNetwork4.dll and QtXml4.dll. Add the other modules you don't need and you'll be good to use only the modules you really need.

I have to verify that last solution since I only read it here but not yet tested it.

Hope this helps.

Live