PDA

View Full Version : QMYSQL Driver not found



pcheng
29th September 2012, 20:05
I created a program in QT with the QMYSQL driver. On my computer and when testing everything seems to work fine with the program. When I compile a release and copy it to another computer I get the message that QMYSQL driver is not loaded.

Any ideas on how to build with MYSQL running?

Thanks,

Pericles

pradeepreddyg95
30th September 2012, 04:40
in your release folder make dir plugins in plugins copy mysql.dll and add below lines in your code


QString pFileName("databasename");

QStringList str;
str.append(".");
qApp->setLibraryPaths(str);
qApp->addLibraryPath("./plugins/");

qDebug()<<"my library path : "<<qApp->libraryPaths();

QLibrary Mysqlib("libMysql.so");
Mysqlib.load();
qDebug()<<"my library loaded"<< Mysqlib.isLoaded();

pcheng
30th September 2012, 10:33
The code says that I should have a libmysql.so.
I added the folder and the libmysql.dll file from C:\Windows
But now it seems that not even my development machine works. When I remove the new code the development machine works but when I added back it does not work.

Thanks,

Pericles

pcheng
30th September 2012, 14:00
I copied the whole plugins folder which includes the sqldrivers folder within it and it seems to do something. Gives me a different error but it might be because it cannot find the remote database and not due to the driver.

I will check that out again by installing MySQL locally and testing on the user computer and then trying to get the remote database to work.

Thanks,

Pericles

pradeepreddyg95
1st October 2012, 03:00
qt default it will search in qt dir(c://qt/plugins) for plugins when you run this executable in different machine you should give the library path otherwise it will search again same path(c://qt/plugins) .

ChrisW67
1st October 2012, 05:22
This has been covered many times in this forum

You need to deploy the Qt MySQL plugin and the MySQL client library that it depends on along with your application. You deployed application should be arranged like this (Windows):


C:\Program Files\
Cool App Dir\
coolapp.exe
qtcore4.dll
qtgui4.dll
qtsql4.dll
...
imageformats\
qjeg4.dll
qgif4.dll
...
sqldrivers\
qmysql.dll // <<< the Qt Mysql plugin
libmysql.dll // <<< The MySQL client library from the MySql distribution

plugins\
// any custom plugin you have written for your program to load directly

There is no need to do anything with the Qt library path if you arrange it like that.

Spitfire
2nd October 2012, 09:04
And here's (http://doc.qt.digia.com/4.7-snapshot/sql-driver.html#qmysql) how to build qt mysql plugin.