[Solved] MySQL Driver C++
-
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
-
Did you install it in the right place?
-
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
-
Try setting Q_DEBUG_PLUGINS=1 in your environment when running your application. You will get debug info on plugin loading, including the sql drivers.
-
[quote author="Andre" date="1341843873"]Try setting Q_DEBUG_PLUGINS=1 in your environment when running your application. You will get debug info on plugin loading, including the sql drivers.[/quote]
Sorry, but where can i find this? Q_DEBUG_PLUGINS=1
-
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"
-
Sorry, my fault, it should be QT_DEBUG_PLUGINS.
-
This is the output (its on pastebin, couldn't post it here..)
-
That's a nice bunch of output. What does it tell you? I could of course analyze it for you, but the point is that it would be more useful for the both of us if you learn to do that yourself...
-
The output is what i understand, it tells me that the dll's and .a files are incompatible sortwise.
But why it is, is something i don't understand. I compiled it using MinGW..
What did i do wrong?
-
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? -
Thanks alot for your time !! really appreciated..
I remember i copied the 64 bit DLL version of libmysql.dll into C:\Windows
That was the problem, now i copied the 32bit, and it works.
Thanks!!
-
Please add a [Solved] tag to the topic title (by editing your first post in the topic) if you feel your problem has been solved.
-
Where will i get
libqsqlmysql4.a
libqsqlmysqld4.a