How to build mysql plugin with static Qt?
-
wrote on 20 Dec 2011, 00:25 last edited by
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 -
wrote on 20 Dec 2011, 03:14 last edited by
Did you remember to add QTPLUGIN to your .pro?
-
wrote on 20 Dec 2011, 13:30 last edited by
no, I didn't add, how I can do this from VS?
-
wrote on 20 Dec 2011, 13:46 last edited by
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. -
wrote on 20 Dec 2011, 16:50 last edited by
I solved the problem by coping libmysql.lib to qt\lib and adding to linker input.
-
wrote on 21 Dec 2011, 13:00 last edited by
[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. -
wrote on 10 Aug 2022, 13:13 last edited by
You must import the plugin with
Q_IMPORT_PLUGIN(QMYSQLDriverPlugin)