Qt static build with static mysql plugin confusion

Posted by bdiloreto on Stack Overflow See other posts from Stack Overflow or by bdiloreto
Published on 2011-11-24T23:05:02Z Indexed on 2012/10/21 11:01 UTC
Read the original article Hit count: 838

Filed under:
|
|
|

I have built a Qt application which uses the MySQL library, but I am confused by the documentation on static versus shared builds.

From the Qt documentation at http://doc.qt.nokia.com/4.7/deployment-windows.html it says:

To deploy plugin-based applications we should use the shared library approach.

And on http://doc.qt.nokia.com/4.7/deployment.html, it says:

Static linking results in a stand-alone executable. The advantage is that you will only have a few files to deploy. The disadvantages are that the executables are large and with no flexibility and that you cannot deploy plugins. To deploy plugin-based applications, you can use the shared library approach.

But on http://doc.qt.nokia.com/latest/plugins-howto.html, it seems to say the opposite, giving directions on how to use static plugins:

Plugins can be linked statically against your application. If you build the static version of Qt, this is the only option for including Qt's predefined plugins. Using static plugins makes the deployment less error-prone, but has the disadvantage that no functionality from plugins can be added without a complete rebuild and redistribution of the application. ... To link statically against those plugins, you need to use the Q_IMPORT_PLUGIN() macro in your application and you need to add the required plugins to your build using QTPLUGIN.

I want to build the Qt libraries statically (for easy deployment) and then use the static MySQL plugin. To do this, I did NOT use the binary distrubtion for Windows. Instead, I've started with the source qt-everywhere-opensource-src-4.7.4 Is the following the correct way to do a static build so that i can use the static MySql plugin?

configure -static -debug-and-release -opensource -platform win32-msvc2010 -no-qt3support -no-webkit -no-script -plugin-sql-mysql -I C:\MySQL\include -L C:\MySQL\lib

  1. This should build the Qt libraries statically AND the static plugin to be linked at run-time, correct? I would NOT need to build the Mysql Plugin from source separately, correct?

  2. If I was to subtitute "-qt-sql-mysql" for "-plugin-sql-mysql" in above, it would include the MySQL driver directly in the QT static libraries, in which case I would NOT need to use the plugin at all, correct?

Thanks for making me unconfused!

© Stack Overflow or respective owner

Related posts about mysql

Related posts about qt