PDA

View Full Version : How to install plugins, addLibrary path and subdirectories, MySQL Plugin



mortoray
9th October 2010, 09:55
This is an informative post to indicate how I finally got a plugin to work, in particular the MySQL plugin.

QT says it looks through the library paths for plugins. It also says that the application directory is also added to the library paths. This is however a bit misleading. When it scans for plugins it looks to specific subdirectories in those paths. For example, when looking for SQL driver plugins it is hard-coded to look in the "sqldrivers" subdirectory.

So this setup will work:

your_app
your_app/plugins
your_app/plugins/sqldrivers

And then you need to addLibraryPath( "/fullpath/your_app/plugins" ).

Windows
To got further however something like the mysql plugin will need libmysql.dll. This will only be searched in the application path and the standard system paths -- this has nothing to do with the library paths in this case. So in the above you need to place this file in the "your_app" directory.

QT_DEBUG_PLUGINS
This environment variable yields a bit of useful information. On windows to get it working you're best setting it in the global environment variable settings -- I had difficulty getting it working if just set in a command prompt. The output goes to the installed MsgHandler.

Lykurg
9th October 2010, 10:11
You don't have to hard code the path to the plugins. It is enough if you put the MySQL plugin at

your_app/sqldrivers

Qt will then find it by it's own. Also if you need to hard code any path at all, better use qt.conf instead of compiling the path in your application.

mortoray
9th October 2010, 10:21
Yes, that directory also works. From what I have written it is clear as to why it works as well, but many people might prefer to use a "plugins" subdirectory for clarity (as the QT install does).

I didn't mean to hard-code the path. Obviously you should determine the path at startup with something like:

QDir plugins( QCoreApplication::applicationDirPath() );
plugins.cd( "plugins" );
addLibraryPath( plugins.absolutePath() );

tniinisto
30th March 2011, 11:30
Hi,

Also struggling with this issue. Managed to compile the mysql plugin and it is working fine with the simulator on pc.
Problem is with this what you have already solved above, how to get the plugin in to the target device with the application.

Have in .pro file the following currently:
...
folder_02.source = plugins/sqldrivers
folder_02.target = plugins/sqldrivers
DEPLOYMENTFOLDERS += folder_02

#file_01.sources = libmysql.dll
#file_01.path = .
#DEPLOYMENT += file_01
...

Do you know what else needs to be defined in the .pro file for this? Libraries?
Have the addLibraryPath() already defined in the source pointing to the plugins directory.
Thanks!