PDA

View Full Version : MySQL 5.5 plugin



Rhayader
2nd March 2011, 15:57
Has anybody compiled a working qmysql plugin with MySQL 5.5?
I have tried in windows both with mingw32 on a windowsXp and with MSVC (x64) on a windows7(x64 ofcourse). Though the plugin seems to have been created successfully with no compile error and is placed in Qt's plugin folder alongside the other sqldrivers plugins it cannot be loaded. QSqlDatabase::isDriverAvailable("QMYSQL") always returns false.

Some notes:
-MySQL's dll libmysql.dll is not anymore in /path/to/MySQL/lib/opt but in lib. path/to/Include haven't changed place.
-I had succesufully compiled MySQL 5.1 many times before, so I am aware of the INCLUDEPATH and LIBS on qmake as well as the reimp and all for mingw.
-I cleaned up the registry cache after every build.
-I am now using Qt 4.7.2 but i also tried it with 4.7.0 (on my windows machines)

In the weekend I' ll try it on my arch linux. Until then any help would be appreciated.
Thanx

wysota
2nd March 2011, 19:16
Is the dll for mysql available for the linker during runtime?

Rhayader
2nd March 2011, 19:28
wysota you are amazing. I thought it was in the PATH but it wasn't. I copied it to MySQL/bin (which I have in PATH) and all works fine. Makes me feel stupid for trying for two days and not seeing this.
Many thanks

SamT
28th March 2011, 06:58
I did the same thing on QT 4.7.2 & MySQL 5.5 with mingw-32 toolchain but bad luck.

Here is what I had done so far.
1. download the QT 4.7.2 lib http://get.qt.nokia.com/qt/source/qt-win-opensource-4.7.2-mingw.exe
2. download the QT 4.7.2 src http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.7.2.zip
3. install the 1 & 2 package in c:\QT folder
4. download the MySQL 5.5 (mysql-5.5.10-win32.msi)
5. install into c:\qt\mysql55
6. in C:\Qt\4.7.2\src\plugins\sqldrivers\mysql
-> qmake "INCLUDEPATH +=c:\qt\mysql55\include" "LIBS +=c:\qt\mysql55\lib\libmysql.lib" mysql.pro
-> make debug
-> make release
-> in debug folder, I got libqsqlmysqld4.a and qsqlmysqld4.dll
-> in release folder, I got libqsqlmysql4.a and qsqlmysql4.dll
-> copy these 4 files into C:\Qt\4.7.2\plugins\sqldrivers
7. in c:\qt\mysql55\lib
-> reimp -d libmysql.lib
-> dlltool -k -d libmysql.def -l libmysql.a
-> copy libmysql.dll into c:\qt\4.7.2\bin
-> copy libmysql.a into c:\qt\4.7.2\lib

Open a project to the check. QSqlDatabase::isDriverAvailable("QMYSQL") always returns false.
What procedure is wrong for me? Please help!

Rhayader
28th March 2011, 08:41
Hi SamT.
Your step 7 should be before 6 so that the qmysql driver can be build with the mingw library

SamT
28th March 2011, 09:15
Thanks Rhayader!
After I re-build qmysql driver with mingw library. it works now!

120decibel
30th March 2011, 07:55
Hi folks

I'm a bit desperate here, I rebuild QT 4.7.2 with VS2008 with the following parameters:

configure -no-qt3support -platform win32-msvc2008 -qt-sql-mysql -plugin-sql-mysql -I C:\MySQL\include -L C:\MySQLßlib -l libmysql

This compiles and buils just fine with nmake.

The I try to build my code with the folloing .pro file:


#! [0]
TEMPLATE = app
LANGUAGE = C++
CONFIG += console
QT += sql

QTPLUGIN += qsqlmysql

HEADERS = mainwindow.h \
csv.h
# myobject.h

SOURCES = main.cpp \
mainwindow.cpp \
csv.cpp

FORMS = ADBI.ui

#! [0]

My simple test code looks like this:



#include <QtCore>
#include <QApplication>
#include <QtSql>
#include <QSqlDatabase>
#include <QtPlugin>
#include "mainwindow.h"

Q_IMPORT_PLUGIN(qsqlmysql)


int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);

//QMainWindow *MW = new MainWindow();

QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");

qDebug() << QApplication::libraryPaths();
//qDebug() << QSqlDatabase::drivers();

//MW->show();

return app.exec();
}


I now get the following linker error:

1>main.obj : error LNK2019:can't find external Symbol ""class QObject * __cdecl qt_plugin_instance_qsqlmysql(void)" (?qt_plugin_instance_qsqlmysql@@YAPAVQObject@@XZ)" in Funktion ""public: __thiscall StaticqsqlmysqlPluginInstance::StaticqsqlmysqlPlug inInstance(void)" (??0StaticqsqlmysqlPluginInstance@@QAE@XZ)".


If I comment out: Q_IMPORT_PLUGIN(qsqlmysql)

it links just fine but then I get: DRIVER NOT LOADED.

Any advice is very appreciated!

Rhayader
30th March 2011, 16:42
The method you are using is for linking statically against your application but I don't think this is what you intended to do, so you should comment out the Q_IMPORT_PLUGIN and all.
So some guesses:
-I see you are using
qDebug() << QApplication::libraryPaths(); in your app. Does this returns the app's directory and the QTDIR/plugins ? If not then you should set the QTDIR environment variable or follow some of the info of how the plugins are loading (in the qt docs http://doc.qt.nokia.com/4.7-snapshot/deployment-plugins.html)
-Is the libmysql.dll in the path? (that was the reason I started this topic) If not copy it from the /MySQL/lib to /MyQSL/bin

ehovaere
5th June 2012, 08:57
hi all,

I'm currently trying to get the mysql driver with Qt 4.8.0 and MySQL Server 5.5.9 with no success...

I've been following the steps described here: http://doc-snapshot.qt-project.org/4.8/sql-driver.html
my qmake (here on Qt 4.8.2):


c:\Qt\4.8.2\src\plugins\sqldrivers\mysql>qmake -o Makefile "INCLUDEPATH+=C:\\Progra~1\\MySQL\\MySQLS~1.5\\incl ude" "LIBS+=C:\\Progra~1\\MySQL\\MYSQLS~1.5\\lib\\libmys ql.lib" mysql.pro


I've been using short names to avoid spaces and I added backslashes to avoid the warning. Anyway, the compiler well find the headers (mysql.h).

But no way, I always encouter the following errors when linking:

debug/qsql_mysql.o:c:\Qt\4.8.2\src\plugins\sqldrivers\my sql/../../../sql/drivers/mysql/qsql_mysql.cpp:362: undefined reference to `mysql_num_fields@4'
debug/qsql_mysql.o:c:\Qt\4.8.2\src\plugins\sqldrivers\my sql/../../../sql/drivers/mysql/qsql_mysql.cpp:369: undefined reference to `mysql_fetch_field@4'
debug/qsql_mysql.o:c:\Qt\4.8.2\src\plugins\sqldrivers\my sql/../../../sql/drivers/mysql/qsql_mysql.cpp:432: undefined reference to `mysql_free_result@4'
debug/qsql_mysql.o:c:\Qt\4.8.2\src\plugins\sqldrivers\my sql/../../../sql/drivers/mysql/qsql_mysql.cpp:438: undefined reference to `mysql_store_result@4'
debug/qsql_mysql.o:c:\Qt\4.8.2\src\plugins\sqldrivers\my sql/../../../sql/drivers/mysql/qsql_mysql.cpp:440: undefined reference to `mysql_free_result@4'
debug/qsql_mysql.o:c:\Qt\4.8.2\src\plugins\sqldrivers\my sql/../../../sql/drivers/mysql/qsql_mysql.cpp:437: undefined reference to `mysql_next_result@4'
debug/qsql_mysql.o:c:\Qt\4.8.2\src\plugins\sqldrivers\my sql/../../../sql/drivers/mysql/qsql_mysql.cpp:446: undefined reference to `mysql_stmt_close@4'
debug/qsql_mysql.o:c:\Qt\4.8.2\src\plugins\sqldrivers\my sql/../../../sql/drivers/mysql/qsql_mysql.cpp:452: undefined reference to `mysql_free_result@4'
debug/qsql_mysql.o:c:\Qt\4.8.2\src\plugins\sqldrivers\my sql/../../../sql/drivers/mysql/qsql_mysql.cpp:496: undefined reference to `mysql_stmt_data_seek@12'
debug/qsql_mysql.o:c:\Qt\4.8.2\src\plugins\sqldrivers\my sql/../../../sql/drivers/mysql/qsql_mysql.cpp:498: undefined reference to `mysql_stmt_fetch@4'
debug/qsql_mysql.o:c:\Qt\4.8.2\src\plugins\sqldrivers\my sql/../../../sql/drivers/mysql/qsql_mysql.cpp:513: undefined reference to `mysql_data_seek@12'
debug/qsql_mysql.o:c:\Qt\4.8.2\src\plugins\sqldrivers\my sql/../../../sql/drivers/mysql/qsql_mysql.cpp:514: undefined reference to `mysql_fetch_row@4'
debug/qsql_mysql.o:c:\Qt\4.8.2\src\plugins\sqldrivers\my sql/../../../sql/drivers/mysql/qsql_mysql.cpp:529: undefined reference to `mysql_stmt_fetch@4'
debug/qsql_mysql.o:c:\Qt\4.8.2\src\plugins\sqldrivers\my sql/../../../sql/drivers/mysql/qsql_mysql.cpp:544: undefined reference to `mysql_fetch_row@4'
debug/qsql_mysql.o:c:\Qt\4.8.2\src\plugins\sqldrivers\my sql/../../../sql/drivers/mysql/qsql_mysql.cpp:565: undefined reference to `mysql_stmt_num_rows@4'
debug/qsql_mysql.o:c:\Qt\4.8.2\src\plugins\sqldrivers\my sql/../../../sql/drivers/mysql/qsql_mysql.cpp:570: undefined reference to `mysql_num_rows@4'
debug/qsql_mysql.o:c:\Qt\4.8.2\src\plugins\sqldrivers\my sql/../../../sql/drivers/mysql/qsql_mysql.cpp:614: undefined reference to `mysql_fetch_lengths@4'
debug/qsql_mysql.o:c:\Qt\4.8.2\src\plugins\sqldrivers\my sql/../../../sql/drivers/mysql/qsql_mysql.cpp:696: undefined reference to `mysql_real_query@12'
etc.....

my OS is Seven 32 bits, my SQL Server is 32 bits.

Do you think I should try with Qt 4.7.2?? Or with an older version of SQL Server ? Problem is the MySQL servers I planned to target are 5.5 ones....
Any idea? Thanks in advance for your help.

Ashtechsmith
7th June 2012, 20:27
Starting from MySQL 5.5.5, the default storage engine for new tables is InnoDB. This change applies to newly created tables that don’t specify a storage engine with a clause such as ENGINE=MyISAM. (Given this change of default behavior, MySQL 5.5 might be a logical point to evaluate whether your tables that do use MyISAM could benefit from switching to InnoDB.)

The mysql and information_schema databases, that implement some of the MySQL internals, still use MyISAM. In particular, you cannot switch the grant tables to use InnoDB.