Cannot load SQL driver in Visual C++ (but works in QtCreator)
I have a QT application that requires the MySql driver. I have both a .pro file to compile the app with QtCreator and a .vcproj for Visual C++ 2008 Express. The code is identical and it compiles without a hitch, but the executable created by Visual C++ Express gives me the following output and refuses to load any driver/plugin:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers:
I used QCoreApplication to identify the location where the plugins are and it seems that both executables have the same path, so they should both see the plugins. One does, and the other doesn't.
The code is standard.
Code:
db.setHostName("localhost");
db.setPort(3306);
db.setDatabaseName("dbase");
db.setUserName("user");
db.setPassword("pwd");
bool ok = db.open();
The same thing happens with the SqlBrowser sample that came with QT, so I don't think the code is the problem.
Re: Cannot load SQL driver in Visual C++ (but works in QtCreator)
see if this thread helps:
http://www.qtcentre.org/forum/f-inst...lem-25071.html
are you running from IDE or from the cmd line?
make sure to create the plugins directory and have the mysql client dll in your path
Re: Cannot load SQL driver in Visual C++ (but works in QtCreator)
For anyone else who bumped into this problem I have to say this - it is much easier to use one of the packages containing QT pre-built binaries for Visual C++ than trying to build it yourself. And the Qt driver (the 4.3 version at least) is awfully hard to get to work, especially when deploying your application (on some machines it works like a charm but on others it can't find the driver, using the same code and binaries) and is not worth the trouble, you are much better off using a dedicated MySql library.