PDA

View Full Version : Build static QT 5.1.0 on Windows x64 with Visual Studio 2012



AsfK
14th August 2013, 17:45
Hi

I never programmed with QT so I do not know too much...
I have:
Windows 7 x64
Visual studio 2012 (Ultimate)
QT 5.1.0

I want to build a static application (only one executable file, without any dll's, etc.) with QT and to be honest I do not know where to start
I found this guide (link (http://tmacdev.com/2013/build-qt-5-1-statically-on-windows/#respond))
And I did all steps.
But I don't know what I need to do now..

If the guide is true:
Let's say I have a working static QT build under the “qtbase” directory
How can I use it and compile a static application ?

Else, if the guide is wrong:
How can I build a static application with QT and VS2012 ?

Thank you very much !

twisted89
16th August 2013, 16:20
In short you'll need the visual studio plugin from here:

http://download.qt-project.org/official_releases/vsaddin/qt-vs-addin-1.2.2-opensource.exe

Once installed load up visual studio and click the QT menu the QT options, here you need to add the path to the static build.
You can then create a new QT project using the normal VS project wizard (there will be a new c++ QT section).

Make sure to also set the project defaults under the QT menu once a new project is created.
There's plenty of online tutorials for the rest as its not specific to static building.

d_stranz
17th August 2013, 05:46
But you will also have to make sure that you turn off all the compile and link flags that would otherwise tell VC++ that you are using a DLL build. Things like QT_DLL and the like. Otherwise, it will import Qt assuming DLL linkage, and you will get a completely different set of "mangled" names (and a zillion link errors for all those "undefined" symbols).

The Visual Studio plugin is not required at all to do this, but it helps. You can build Qt apps in Visual Studio without it, so long as you specify the right compile options and libraries. The Qt plugin makes it easier, but only if you are following the standard method of making apps. Static builds are not standard.

By the way, if you are using Qt open source in a commercial application, it is a violation of the LGPL license to link statically. You must buy a Qt Commercial license if you want to build a statically-linked commercial Qt app.

AsfK
18th August 2013, 13:38
Thank you very much !
to both of you