How to build mysql plugin with static Qt?
I have libraries bulit both static and shared. In shared library I built mysql plugin and it works good. In static library I did the same actions to build plugin and plugin was bulit, but when I want to use it QSqlDatabase::lastError shows "Driver not loaded" and if I use it by #include <QtPlugin>, Q_IMPORT_PLUGIN (qsqlmysql) there is error: main.obj : error LNK2019: unresolved external symbol "class QObject * __cdecl qt_plugin_instance_qsqlmysql(void)" (?qt_plugin_instance_qsqlmysql@@YAPAVQObject@@XZ) referenced in function "public: __thiscall StaticqsqlmysqlPluginInstance::StaticqsqlmysqlPluginInstance(void)" (??0StaticqsqlmysqlPluginInstance@@QAE@XZ). Anybody can helps me?
Qt 4.7.4 + VS 2010
Did you remember to add QTPLUGIN to your .pro?
no, I didn't add, how I can do this from VS?
Isn't there a contradiction of PlugIn and static linking?
"Here":http://developer.qt.nokia.com/doc/qt-4.8/qpluginloader.html#id-cad524e7-589d-42ca-ab1b-3a493da9284b loading at run-time. In a static build you do not load at runtime anymore IMHO.
I solved the problem by coping libmysql.lib to qt\lib and adding to linker input.
[quote author="alexxx_1992" date="1324399804"]I solved the problem by coping libmysql.lib to qt\lib and adding to linker input.[/quote]
Why did you add an additional directory to "Additional Library Directories" under "Linker" of your project properties?
This is as you have to do in msvc 2005. I guess the naming did not much for msvc 2010.