2
votes

After having searched and tried for hours, I could not get how to statically link the libraries to my exe. So I tried to copy the dependencies into the exe folder. I made a test program that changed the label on the click of a button. That was 14 mb. what should I do ? I am using icudt51.dll icuin51.dll icuuc51.dll libgcc_s_dw2-1.dll libstdc++-6.dll libwinpthread-1.dll Qt5Core.dll Qt5Gui.dll Qt5Widgets

3
you can't link statically to a .dll, do you mean you linked dynamically in the end?brunocodutra
Be aware that to link statically with Qt libraries, your code has to be licensed under either the GPL or LGPL, or you have to pay a commercial Qt license. If your code doesn't meet one of those conditions you are not allowed to link statically with Qt.syam
Yes, Qt files are big!mox
What have you tried to link statically? (You'll need to build itself with the -static flag)Frank Osterfeld
I don't know how to do -static. where should I add that? I am absolutely new.harveyslash

3 Answers

7
votes

The only thing I see possible is to use upx to compress your executable. You won't even notice the difference. It decompresses and executes your program so fast.

http://upx.sourceforge.net/

4
votes

There are many solutions to your problem:

1- Use Qt 4.8.5, there is not much difference between Qt 5 and Qt 4.8. It will help you because Qt 4.8.5 is not compiled with default support for QtWebkits, which means no dependency on icudt51.dll icuin51.dll icuuc51.dll files.

2- If you wish to use Qt 5, you will need to recompile it with webkit disabled, that will also get you rid of above dependencies. For details check this: post

1
votes

If you want to link Qt 5.1.1 statically as-is (without 3rd party patches), it only works for the in-source builds. Shadow static builds fail due to a bug in zlib cloning. A upx-ed simple executable that only uses widgets will be under 5mb, more like 3mb. It's in the same ballpark for Qt 5 and Qt 4. I'm compiling both statically using MSVC2012 and it works just fine. Those are full static builds, meaning that Qt library is static and the C/C++ runtime is static as well. The only dependencies are on system DLLs. Makes life easy for everyone, although the release build can take a few minutes and forget about building on a 32 bit system.

The startup times of staticly-built executables are amazing. It's pretty much instantaneous :)