PDA

View Full Version : problem with mysql drivers windows



danilodsp
4th June 2011, 22:30
Hello everybody,

I'm trying to install the MySQL drivers for Qt on Windows 7.
I have already installed MinGW, Qt, QtCreator, MySQL connector and MySQL Server. I'm following the steps in doc "SQL Database Drivers" which comes in QtCreator.

The steps are:
- Install MinGW-5.1.6.exe in, e.g. C:\MinGW.
- Extract mingw-utils-0.3.tar.gz into, e.g. C:\MinGW.
- Add the path for MinGW-5.1.6.exe to your PATH variable, e.g. C:\MinGW\bin;
- Extract the Qt sources, (qt-everywhere-opensource-src-4.6.2.zip), into, e.g. C:\Qt.
- Add the path for the eventual Qt binary to your PATH variable, e.g. C:\Qt\4.6.2\bin;.
- Install MySQL (mysql-5.1.35-win32.msi), customizing the components. Select only the headers and libraries. Install in, e.g. C:\MySQL\MySQL51.
- Open the DOS prompt, go to C:\MySQL\MySQL51\lib\opt, and run the following commands:
reimp -d libmysql.lib
dlltool -k -d libmysql.def -l libmysql.a
- Open the DOS prompt, go to C:\Qt\4.6.2 and run the following commands:
configure.exe -debug-and-release -platform win32-g++ -qt-sql-mysql -l mysql -I C:\MySQL\MySQL51\include -L C:\MySQL\MySQL51\lib\opt
mingw32-make sub-src
This step takes a long time.
- Open the DOS prompt, go to C:\Qt\4.6.2\src\plugins\sqldrivers\mysql and run the following command:
qmake "INCLUDEPATH+=C:\MySQL\MySQL51\include" "LIBS+=-L. mysql" mysql.pro
- Now the following libraries are ready in C:\Qt\4.6.2\plugins\sqldrivers.
libqsqlmysql4.a
libqsqlmysqld4.a
qsqlmysql4.dll
qsqlmysqld4.dll
- To use the SDK and QtCreator directly, copy these libraries to your C:\Qt\...\qt\plugins\sqldrivers\, and copy C:\MySQL\MySQL51\lib\opt\libmysql.dll to your C:\Qt\...\qt\bin\.

In step configure.exe and mingw32 an error occurs in a file claiming qsql_mysql.h.
Then inside that file has an include that does not exist, mysql.h. Then I copy the mysql.h that comes with the MySQL server and continue the problem.

What the solution?

Added after 57 minutes:

I tried with the mysql binary files and still continue the problem.
In step mingw32 show:
C:\Qt\2010.05\qt\src\sql/drivers/mysql/qsql_mysql.cpp:312: undefined reference to `mysql_stmt_errno@4'
./tmp\obj\debug_shared\qsql_mysql.o:C:\Qt\2010.05\qt \src\sql/drivers/mysql/qsql_mysql.cpp:358: undefined reference to `mysql_stmt_result_metadata@4'
...

when do the qmake,
C:\Qt\2010.05\qt\src\plugins\sqldrivers\mysql>qmake "INCLUDEPATH+=C:\mysql-connector-c-noinstall-6.0.2-winx64\include" "LIBS+=-L. mysql" mysql.pro
show:
WARNING: (internal):1: Unescaped backslashes are deprecated.
WARNING: (internal):1: Unescaped backslashes are deprecated.
WARNING: (internal):1: Unescaped backslashes are deprecated.

In the C:\Qt\...\plugins\sqldrivers no have files qsqlmysql4.dll, qsqlmysqld4.dll.

pkj
5th June 2011, 09:29
Looks like your mysql driver is not loaded. Only qmake will not do it. You will have to build it too. also replace the forward slashes with backslashes... c if it works...

danilodsp
5th June 2011, 15:34
I think I'll quit.
I tried several ways and could not.
I will try to use API MySQL for C/C++.

pkj
5th June 2011, 16:26
Due to licensing issues Qt doesn't bundle the dll's. It makes life a little difficult for those who are starting with databases other than sqlite. I faced similar issues when integrating Firebird(Ibase) and postgre. But once done the qt api is miles ahead than any other api for database connectivity and implementation logic. You might want to persist and ask the right questions, the informative people in this forum will make it through....Just my 2cents...:)

danilodsp
5th June 2011, 21:46
Due to licensing issues Qt doesn't bundle the dll's. It makes life a little difficult for those who are starting with databases other than sqlite. I faced similar issues when integrating Firebird(Ibase) and postgre. But once done the qt api is miles ahead than any other api for database connectivity and implementation logic. You might want to persist and ask the right questions, the informative people in this forum will make it through....Just my 2cents...:)

hmm .. ok.
So I will persist.

Initially I apologize for my English.

From the beginning.
I'm following the docs with the title "How to build the MySQL driver for MinGW users".
He says to install:
- MinGW-5.1.6.exe
- mingw-utils-0.3.tar.gz
- Qt sources, eg qt-everywhere-opensource-src-4.6.2.zip
- mysql-5.1.35-win32.msi

In QT, I installed "qt-sdk-win-opensource-2010.05" which I believe is the same thing, but now I'm suspicious that Qt sources has more something.
The doc talks about a win32, the my is win64, I believe that no problem.

Everyone talks about the directory "C:\MySQL\MySQL51\lib\opt", but in my disk that does not exist. Here is "C:\Program Files\MySQL\MySQL Server 5.5\lib" do not have the directory "opt".

Now I will reinstall everything and try again.

pkj
6th June 2011, 07:32
Best of luck... You may want to see these links... Thread on mysql on xp (http://www.qtcentre.org/threads/33251-Building-MySQL-QT-Drivers-on-Windows-XP) and How to mysql on qt (http://www.lemon-factory.com/2010/04/24/qt-building-the-mysql-plugin-on-windows/) Also ... while compiling library for sql, pro file should be able to see into the headers of mysql and libs should point to dlls. You may have to change the pro file accordingly.