[Solved] MySQL Driver C++
-
Hello all,
Im getting crazy, i've searched all over the internet, i've read 1000 topics and internet pages about the MySQL driver compile.
This is an example: http://www.seppemagiels.com/blog/create-mysql-driver-qt-windows
But i can't get it working...
First of all, i've seen every1 having a folder called "mysql" in their QT folder (C:\QtSDK\Desktop\Qt\4.8.1\msvc2010\plugins\sqldrivers\mysql)
I don't have it, but i made it manually.... ???
Second, when i try to "qmake" it says mysql.pro is missing.. (so i also made this file manually)
Third, when i then try to "qmake" it says "Unescaped backslashes are deprecated"When i did this steps, it makes some files in the (C:\QtSDK\Desktop\Qt\4.8.1\msvc2010\plugins\sqldrivers\mysql) folder.
MakeFile.Release
MakeFile.DeBug
etc...But not the files i need!
I can't seem to find a clear tutorial that handles all these errors, because i don't know how to fix this..
Thanks!! i hope its clear.
P.S: Ive installed Mysql server 5.5, and also the MySQL connecter.
-
Did you try "this":http://ieatbinary.com/2011/07/11/how-to-enable-mysql-support-in-qt-sdk-for-windows/ guide?
-
[quote author="Andre" date="1341834310"]Did you try "this":http://ieatbinary.com/2011/07/11/how-to-enable-mysql-support-in-qt-sdk-for-windows/ guide?[/quote]
Yes, thanks, im keeping stucked @ "unescaped backslashes deprecated"
https://dl.dropbox.com/u/40400405/unescaped_backslashes.png
So it doesn't compile... (there should be compiled files in release/debug folder, but there aren't any.)
Edit:
I've found the problem, i must use \ instead of ..
Now up to my next problem, which is i can't use "mingw32-make" -
Ok, so now i've successfully compiled the driver files, but my QtCreator doesn't see it.
@#include <QtCore/QCoreApplication>
#include <QtSQL>int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
qDebug() << QSqlDatabase::drivers();
return a.exec();
}@Also added "QT+= sql " to my project file..
What can be the problem? :O
-
I've put all the nescessairy files in "C:\QtSDK\Desktop\Qt\4.8.1\mingw\plugins\sqldrivers"
qsqlmysql4.dll
qsqlmysqld4.dll
libqsqlmysql4.a
libqsqlmysqld4.aI've tried different compilers too (In QT Creator)
If i copy the dll/a files to other plugin directories, and i use that compiler, it doesn't show me any drivers at all.. (like version 4.7.4)
This is what i mean: https://dl.dropbox.com/u/40400405/compilers.png
-
-
You can set it as an environment variable. You can even do that directly from Qt creator: go to the Projects tab on the right side, and swich to the right project and the Run Settings (at the top of the tab). In the list of options, you'll find a Run Environment box. Expand it using the Details button on the right, and add the Q_DEBUG_PLUGINS variable to the list, giving it the value 1.
-
Thanks, i've found it.. But where can i find debug info? because it doesn't show up in "Application Output"
-
This is the output (its on pastebin, couldn't post it here..)
-
Let us first filter it down to the relevant entries, the ones about your mysql dll's:
[quote]
QFactoryLoader::QFactoryLoader() looking at "C:/QtSDK/Desktop/Qt/4.8.1/mingw/plugins/sqldrivers/qsqlmysql4.dll"
In C:/QtSDK/Desktop/Qt/4.8.1/mingw/plugins/sqldrivers/qsqlmysql4.dll:
Plugin uses incompatible Qt library
expected build key "Windows mingw debug full-config", got "Windows mingw release full-config"
"The plugin 'C:/QtSDK/Desktop/Qt/4.8.1/mingw/plugins/sqldrivers/qsqlmysql4.dll' uses incompatible Qt library. Expected build key "Windows mingw debug full-config", got "Windows mingw release full-config""
not a plugin
[/quote]
Ok, seems you are running a debug version of your app, with a debug Qt library, and that means you cannot load a release version... Makes sense, and the lack of a 'd' in the name of the library also indicates a release version. So far, no worries.
[quote]
QFactoryLoader::QFactoryLoader() looking at "C:/QtSDK/Desktop/Qt/4.8.1/mingw/plugins/sqldrivers/qsqlmysqld4.dll"
QLibraryPrivate::loadPlugin failed on "C:/QtSDK/Desktop/Qt/4.8.1/mingw/plugins/sqldrivers/qsqlmysqld4.dll" : "Cannot load library C:/QtSDK/Desktop/Qt/4.8.1/mingw/plugins/sqldrivers/qsqlmysqld4.dll: "
"Cannot load library C:/QtSDK/Desktop/Qt/4.8.1/mingw/plugins/sqldrivers/qsqlmysqld4.dll: "
could not load
[/quote]
Now it starts to get serious. Qt tried to load this plugin, but failed. The library failed to load, but it does not tell you why. Time to debug that further. Usually, when a library fails to load, it misses a dependency. So, get yourself a copy of the dependency walker tool to figure out what library the driver is trying to load and fails at. I can guess which one though: a core mysql library. Did you really follow the guide I linked to before? Including step 6?