PDA

View Full Version : MySQL driver - Very strange problem. PLEASE HELP ME. Thanks.



diego
2nd June 2009, 01:56
Hi all.
I am trying to connect Mysql with QT on Window XP.
I made steps:
1. Installed QT SDK
2. Installed MySQL
3. I run Qt Command Prompt to Build the QMYSQL Plugin on Windows.


cd %QTDIR%\src\plugins\sqldrivers\mysql
qmake "INCLUDEPATH+=C:\mysql\include" "LIBS+=C:\mysql\lib\opt\libmysql.lib" mysql.pro
make

It occurs to me a message :



...
C:/Qt/2009.02/qt/src/plugins/sqldrivers/mysql/../../../sql/drivers/mysql/qsql_my
sql.cpp:1419: undefined reference to `mysql_real_escape_string@16'
collect2: ld returned 1 exit status
make[1]: *** [debug\qsqlmysqld4.dll] Error 1
make[1]: Leaving directory `C:/Qt/2009.02/qt/src/plugins/sqldrivers/mysql'
make: *** [debug] Error 2


What happends with me. Please help me.
Thanks.
Diego.

fnmblot
3rd June 2009, 15:47
Did you run the reimpl command successfully? That is most likely the problem. Follow the directions here (http://wiki.qtcentre.org/index.php?title=Building_the_QMYSQL_plugin_on_Wind ows_using_MinGW) to a T.

diego
4th June 2009, 02:27
Thanks.

I will try to make it now.

diego
4th June 2009, 08:38
Did you run the reimpl command successfully? That is most likely the problem. Follow the directions here (http://wiki.qtcentre.org/index.php?title=Building_the_QMYSQL_plugin_on_Wind ows_using_MinGW) to a T.

Hi all.

I am trying to connect mysql with QT on window xp system.

I made step:

1. Installed mysql
2. Installed QT SDK
3. I copied mingw-utils-0.3 to %QTDIR%/bin)
4. I did




1. Open a Qt Command Prompt and go to : C:\mysql\lib\opt
2. Run : dlltool -k --input-def libmysql.def --dllname libmysql.dll --output-lib C:\Qt\2009.02\mingw\lib\libmysql.a
3. reimp libmysql.lib to produce the liblibmysql.a file. It had done.
4. Go to %QTDIR%/src/plugins/sqldrivers/mysql
5. Run the following command: qmake -o Makefile "INCLUDEPATH+=C:\mysql\include" "LIBS+=C:\mysql\lib\opt\liblibmysql.a" mysql.pro
6. Run make - this should build the qsqlmysql.dll and libqsqlmysql.a files in the %QTDIR%/plugins/sqldrivers directory.
7. Copy the libmysql.dll file from the MySQL installation's bin directory to a directory in %PATH% (e.g. %QTDIR%/bin).


I made i simple QT connecttion



QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("209.59.209.13");
db.setDatabaseName("test");
db.setUserName("tara");
db.setPassword("d5aquExV");


it still has a wrong message


QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC


Please help me. What step i was wrong or what happends to me.
Thanks in advance.
Diego

fnmblot
5th June 2009, 16:46
Now that you have made the plugin, you have to update the .pro file with QT += sql

diego
8th June 2009, 06:19
After making pluin. I made 3 simple files for my example
But now it sitll dont run.
Please help me discover this problem

B.Pro file (Project name is B):


QT += sql
TARGET = B
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui


main.cpp :


#include <QtGui/QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}


MainWindow.cpp


#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtSql>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
createConnection();
}

MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::createConnection()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("127.0.0.13");
db.setDatabaseName("ytr");
db.setUserName("root");
db.setPassword("d5aquE");
}


It still appears a message to me that:


QMYSQL driver not loaded


Thanks so much.

tpf80
11th June 2009, 04:00
is the qsqlmysqld4.dll in a path that your compiled program is looking for? for example, try making a "sqldrivers" folder within the folder that your compiled EXE is in, and place the "qsqlmysql4.dll" in that folder and see what happens.

igorbrp
13th August 2009, 16:11
Hi all,

I was using the link http://wiki.qtcentre.org/index.php?title=Building_the_QMYSQL_plugin_on_Wind ows_using_MinGW and also received the message:


QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC

Now able to put the files qsqlmysqld4.dll and libqsqlmysqld4.a in


C:\Qt\2009.03\qt\plugins\sqldrivers

I have not done a detailed test, but the driver was loaded.

Thanks