PDA

View Full Version : Qt 4.1 OS on Windows & mysql



neeko
5th January 2006, 05:55
Hi there,
I have downloaded the binary installer for QT 4.1.0 Open Source version, with the MinGW compiler, and installed it into c:\qt\4.1.0

I have mysql 4.1 running on my WinXP pc, and I have downloaded the header files and put them into c:\mysql

My issue is that it appears that I have to compile the mysql driver, according to these trolltech.com docs (http://doc.trolltech.com/4.1/sql-driver.html#building-the-drivers-using-configure)

Try as I might, when following these steps exactly, all I get are "undefined reference" errors when running make. EG:

tmp\obj\release_shared\qsql_mysql.o(.text+0x6c7):q sql_mysql.cpp: undefined reference to `mysql_stmt_error@4'
tmp\obj\release_shared\qsql_mysql.o(.text+0x6db):q sql_mysql.cpp: undefined reference to `mysql_stmt_errno@4'

I should point out that I can compile a basic "hello world" app using QT just fine, so I'm reasonably sure that QT and MinGW are installed and working ok.

Can someone help me to get the mysql driver working please?

thanks

MarkoSan
5th January 2006, 11:04
Read this and then try:
Building the Plugins Manually QMYSQL for MySQL 3.x and MySQL 4.x

General Information
MySQL 3.x doesn't support SQL transactions by default, although there are some backends which offer this functionality. Recent versions of the MySQL client libraries (>3.23.34) allow you to use transactions on those modified servers.
If you have a recent client library and connect to a transaction-enabled MySQL server, a call to the QSqlDriver::hasFeature( QSqlDriver::Transactions (http://www.qtcentre.org/forum/qsqldriver.html#DriverFeature-enum) ) function returns true and SQL transactions can be used. If the plugin is compiled against MySQL 4.x client libraries, transactions are enabled by default. You can find information about MySQL on http://www.mysql.com (http://www.mysql.com/)

How to Build the Plugin on Unix and Mac OS X
You need the MySQL header files and as well as the shared library libmysqlclient.so. Depending on your Linux distribution you may need to install a package which is usually called "mysql-devel".
Tell qmake (http://www.qtcentre.org/forum/qmake-manual.html#qmake) where to find the MySQL header files and shared libraries (here it is assumed that MySQL is installed in /usr/local) and run make:
cd $QTDIR/src/plugins/sqldrivers/mysql
qmake -o Makefile "INCLUDEPATH+=/usr/local/include" "LIBS+=-L/usr/local/lib -lmysqlclient" mysql.pro
make

How to Build the Plugin on Windows
You need to get the MySQL installation files. Run SETUP.EXE and choose "Custom Install". Install the "Libs & Include Files" Module. Build the plugin as follows (here it is assumed that MySQL is installed in C:\MYSQL):
cd %QTDIR%\src\plugins\sqldrivers\mysql
qmake -o Makefile "INCLUDEPATH+=C:\MYSQL\INCLUDE" "LIBS+=C:\MYSQL\LIB\OPT\LIBMYSQL.LIB" mysql.pro
nmakeIf you are not using a Microsoft compiler, replace nmake with make in the line above.

wysota
5th January 2006, 11:22
Hi there,
I have downloaded the binary installer for QT 4.1.0 Open Source version, with the MinGW compiler, and installed it into c:\qt\4.1.0

I have mysql 4.1 running on my WinXP pc, and I have downloaded the header files and put them into c:\mysql

Are you sure you have header files from mysql 4.1 and not 5.0? I don't remember seeing "mysql_stmt_errno" in MySql 4 API.

neeko
5th January 2006, 21:50
Wysota: I have been trying both sets, so maybe I've gotten them mixed up. I'll delete the directory, reinstall them and try again.

Markosan: This looks similar to the instructions on Trolltech's site as in my first post, that error during Make. I'll reinstall the headers first then try again.

Thanks

fane
6th January 2006, 00:02
Not sure if this link (http://www.korone.net/bbs/board.php?bo_table=qt_lecture&wr_id=173) will help but it worked for me (Qt 4.0.0, MySQL 4.1.11, WinXP pro)

MarkoSan
6th January 2006, 07:33
I had to manualy edit the makefile for sql and then worked, because, in my case, make could not find library files.

dimitri
7th January 2006, 20:50
How did you have to edit Makefile?

Are you using the MinGW version of MySQL? See for example:
QT 4.1 Windows and MySQL (http://www.qtforum.org/thread.php?threadid=15879&sid=b38ec50ca91f047be12446fedde8cded)

cioannou
8th January 2006, 13:43
Wysota: I have been trying both sets, so maybe I've gotten them mixed up. I'll delete the directory, reinstall them and try again.

Markosan: This looks similar to the instructions on Trolltech's site as in my first post, that error during Make. I'll reinstall the headers first then try again.

Thanks


This worked for me too...


1) Creating the MySQL client library.
- - - - - - - - - - - - - - - - - - -

Unfortunatly, the client libraries (libmysql.ddl and libmysql.lib)
shipped with MySQL are compiled with the M$ compiler and are causing
problems with try to link them with the MinGW compiler. Therefore,
we first need to create a MinGW compatible library out of libmysql.dll.
This can be done by taking the following steps:

1. cd c:\mysql\lib\opt (c:\mysql is where our MySQL is installed)
2. reimp -d libmysql.lib (reimp comes with MinGW utilities)
3. dlltool -k --input-def libmysql.def --dllname libmysql.dll --output-lib

libmysql.a

Now we have the MinGW compatible library called libmysql.a

MarkoSan
8th January 2006, 18:26
How did you have to edit Makefile?

Are you using the MinGW version of MySQL? See for example:
QT 4.1 Windows and MySQL (http://www.qtforum.org/thread.php?threadid=15879&sid=b38ec50ca91f047be12446fedde8cded)

I manually added path to lib files, since the make could not find them. I use Qt 4.0.1 Commercial under WinXP Pro.

dimitri
14th January 2006, 16:28
Which MySQL are you using? Obe built for MinGW? Where did you get it from?

niko
31st January 2006, 21:22
See this thread:
http://lists.trolltech.com/qt-interest/2005-07/thread00014-0.html

that worked for me
(Win2k, Qt 4.1 GPL, MinGW, MySQL4 default win32 build (not self-compiled))