Qt build that can link statically out of the box?
I have used开发者_开发百科 Qt to build a small application. It turns out that I need to reconfigure and Qt from scratch in order to be able to link statically. I've done it before, and I remember that it was a very long process.
So does anyone know a Qt SDK installer that provides the ability for static linking out of the box?
In addition to Martin Beckett's answer.
Be careful with licenses!
If you use Qt under (L)GPL license terms and distribute your own app under (L)GPL too, than everything is OK.
Of course if you want to make proprietary software than the situation is more complicated. Very roughly, the end user should be able to (modify and) recompile Qt and use your application with the (modified and) recompiled version of the library. To achieve this with static linking, without making your source code available to the end users, it is enough to provide a linkable object code so they can re-link with their modified library.
Also if I remember correctly if you use LGPL Qt and provide source code, you don't have to use the LGPL license for your own code. You can compose your own license (if you are a lawyer =)) and deny any rights other than that the user can re-compile and re-link.
If you want to statically link Qt you need the commercial license - which comes with static libs.
EDIT - yes you could arguably provide the user with some sort of patch tool to allow them to switch your statically linked Qt lib with their own version and remain within the LGPL - but really?
For Unix / Windows / Mac OS-x, it's as easy as adding the -static
option to configure:
-static ............ Create and use static Qt libraries.
The deployment page links to specifics about each OS.
A very detailed post on building a static version of Qt with both the MS and gcc toolsets can be found here.
精彩评论