PDA

View Full Version : DLL independent development?



Sia
29th November 2011, 09:10
I'm aware that this have been asked throughout the years that QT has existed, but the question still boggles me.

Can we link the libraries statically to our Binary, so that our C++ code truly differs from Java and .NET based coding?
By libraries, i mean all of them, as in: Mingwm10.dll, QTcore.dll, etc, etc(Might have gotten the names wrong).

And if they are statically linked to our Binary, how much space would it take up?
I would appreciate 'in-depth' answers.



Regards, Franck.

ChrisW67
29th November 2011, 09:34
Can we link the libraries statically to our Binary,
Yes, within the constraints of their licences. If you statically link to GCC components then you may make your code subject to the GPL. You cannot capture all the dependencies; for example the Microsoft C runtime library will still be a DLL dependency.

so that our C++ code truly differs from Java and .NET based coding?
I don't know what difference you are referring to: Java and .Net require a set of runtime libraries, so will your C++ application (i.e. msvcrt.dll). You can bundle the needed non-standard dependencies with your application in all three cases.

By libraries, i mean all of them, as in: Mingwm10.dll, QTcore.dll, etc, etc(Might have gotten the names wrong).
mingwm10.dll will not be needed for recent MingW (http://thread.gmane.org/gmane.comp.gnu.mingw.user/36738).


And if they are statically linked to our Binary, how much space would it take up?

At least as much space as the compiled size of your program plus every Qt, C++ or C runtime function/class that is used directly or indirectly. I guess the worst case is that you get a single executable that's about the same size as all the DLLs put together.

Sia
2nd December 2011, 09:43
"the Microsoft C runtime library will still be a DLL dependency."
I'm not sure as to what you are implying. QT is a cross-operating system development platform.
.NET (Microsoft visual studio) is not cross-platform. And to my knowledge, i do not use any of the facilities of .NET based components.

"mingwm10.dll will not be needed for recent MingW (http://thread.gmane.org/gmane.comp.gnu.mingw.user/36738)." Thank you :p Just a question, though, what are the 'mthreads'? Does QT not provide threading within their core library?


"At least as much space as the compiled size of your program plus every Qt, C++ or C runtime function/class that is used directly or indirectly"
It was a question directed towards: 'if anyone had tried it'. I heard someone got a size of 30(+)MB. Not sure if such claims were/are true, though.

Spitfire
5th December 2011, 09:49
It was a question directed towards: 'if anyone had tried it'. I heard someone got a size of 30(+)MB. Not sure if such claims were/are true, though.
It's possible.
Depending on how many libraries you link against you could get that big binary.

For example:
Empty statically linked release Qt Gui project is 6.5MB big ( QCore and QGui static release libraries are together 16.4MB big ),
Empty statically linked debug Qt Gui project is 140MB big ( QCore and QGui static debug libraries are together 223MB big ),
(on my windows box with qt 4.7.4 and mingw32)

So the binary most likely will be smaller than sum of libraries it links against but like ChrisW67 said, in worst case it may be as big as sum of their sizes.

ChrisW67
5th December 2011, 11:57
"the Microsoft C runtime library will still be a DLL dependency."
I'm not sure as to what you are implying. QT is a cross-operating system development platform.
.NET (Microsoft visual studio) is not cross-platform. And to my knowledge, i do not use any of the facilities of .NET based components.

I didn't mention .Net, and I didn't say that Qt was not cross-platform. I said that, on Windows, even a statically linked Qt application may have a runtime dependency on Microsoft's C runtime library because it is generally assumed to be present and is not linked statically. You can probably do it with Microsoft's compiler.

Just a question, though, what are the 'mthreads'? Does QT not provide threading within their core library?
Yes, Qt provides platform-independent threading classes to the application programmer. Internally, these classes are built on top of the host operating system's threading libraries.
MingW uses a library called mthreads on top of Windows and this will replace functionality in the mingwm10.dll.