Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QMYSQL driver not loaded in release, working in debug

Tags:

c++

linker

qt

qt5

I'm currently working on a Qt5 app, that involves using a mysql database with QMYSQL. It works like a charm during a debug session, but when I compile it in release, I get the error :

Driver not loaded. Driver not loaded.

(Yeah, it actually appears twice).

I already tried including all DLLs, like this :

enter image description here

But this is not working at all, I tried tweaking the qmake options, nothing worked. Is there a trick I'm not aware of ?

Note : The MySQL driver I use is the one I compiled myself.

like image 700
Rogue Avatar asked Nov 09 '22 12:11

Rogue


1 Answers

First of all you should probably not include any "d" ended libraries in your release. "d" means debug and they are used by Qt when you compile in debug and debug builds are linked to those.

Anyway the commentators to your OP are right, the reason why this fails is most likely due to missing MySQL driver in your environment. You either need to include it in your environment or place where your app can automatically load it (like Windows/ directory on Windows or MySQL directory when installed and added to path environment variable) or add it directly to your app's directory.

You can see default locations your app tries to load from by calling QLibrary::libraryPaths then you can check if the MySQL driver is in any of those locations (it is likely not hence the error). And of course as suggested use Dependency Walker on the qmysql.dll and also your app to see which dependencies failed to load.

Bttom line: You need MySQL driver itself, qmysql.dll depends on it.

like image 200
Resurrection Avatar answered Nov 15 '22 04:11

Resurrection