Qt-interest Archive, July 2005
MySQL 4.1 and win32 Qt4
Message 1 in thread
Hi,
Does somebody know how to build/install the mysql plugin using:
- MySQL 4.1
- Qt4 OpenSource Win32/MinGW
Thanks,
B.
_________________________________________________________________
Free blogging with MSN Spaces http://spaces.msn.com/?mkt=nl-be
Message 2 in thread
Bert Wizzy írta:
>
> Hi,
>
> Does somebody know how to build/install the mysql plugin using:
> - MySQL 4.1
> - Qt4 OpenSource Win32/MinGW
>
> Thanks,
>
> B.
Try passing the "-plugin-sql-mysql" switch to configure and make sure
you have the MySQL ?devel? files (include headers, and libmysql.lib)
installed.
Message 3 in thread
Hi,
> Does somebody know how to build/install the mysql plugin using:
> - MySQL 4.1
> - Qt4 OpenSource Win32/MinGW
In theory, follow these instructions and it should work out of the box:
http://doc.trolltech.com/4.0/sql-driver.html#building-the-drivers-using-configure
Are there any problems following these instructions?
You'll have to specify the location of MySQL headers and libraries using
-I and -L otherwise configure can't find them. Something like this:
configure -I/usr/foo/bar/mysql/include -L/usr/foo/bar/mysql/lib
This is the reason for the first errors described here:
http://lists.trolltech.com/qt-interest/2005-06/thread01072-0.html
http://lists.trolltech.com/qt-interest/2005-07/thread00000-0.html
Then there may be an additional problem that could a Qt bug. The build
system may attempt to link with libmysql.lib (Windows-style) instead of
libmysql.a (MinGW-style):
http://lists.trolltech.com/qt-interest/2005-07/thread00000-0.html
You'll have to work around that. I believe that changing
src/sql/drivers/drivers.pri from:
win32 {
!contains( LIBS, .*mysql.* ):LIBS *= libmysql.lib
to:
win32 {
!contains( LIBS, .*mysql.* ):LIBS *= -lmysql
would fix the root of the problem for MinGW.
If that's indeed a Qt bug, it will hopefully be fixed in upcoming releases.
--
[ signature omitted ]
Message 4 in thread
Hi,
>http://doc.trolltech.com/4.0/sql-driver.html#building-the-drivers-using-configure
>
>Are there any problems following these instructions?
I followed the instructions provided in the above webpage, but there are
compile errors.
The first error I got, was due to a problem in the mysql.pro file. Some
wrong library got linked
in. I have fixed that.
The second problem I got, were undef symbols. However when I look into the
mysql library, the
symbols are there. So, I did not know what the problem was. But ... after
some google hours I found that the mysql library was build using the
__stdcall calling convention and this is not compatible with MinGW.
This is what I have done to successfully build the mysql plugin for MinGW:
(I writing a small HOWTO - I also did not test if the plugin actually works
... will be my next step)
The problem is not really with Qt, but it is about creating/obtaining
MySQL libraries that compile/link fine with MinGW. The problem has
something to do with function calling convention.
This is a small HOWTO, explaining on how to convert the MySQL libraries
to something which is usable with MinGW.
1) Go to the MySQL lib directory:
# cd <path_where_mysql_is_installed>\lib\opt
2) Produce a DEF file:
# pexports libmysql.dll | sed "s/^_//" > libmysql.def
*NOTE: pexports and sed come with MinGW utilities and msys.
3) Create the MinGW import library:
# dlltool -U -d libmysql.def -l libmysql.lib.a
At this moment, a MinGW compatible library libmysql.lib.a is created.
But, the headers are still written this way they are using the M$
calling convention. We need to change this.
4) Open the header <path_where_mysql_is_installed>\include\mysql.h
and change the following around line 44:
Change:
#define STDCALL __stdcall
into:
#undef STDCALL
#define STDCALL
*NOTE: The following is more a hack instead of a solution.
Maybe you can come up with a cleaner patch.
Use some extra #ifdef's or something ...
Now, we will build the Qt MySQL plugin using MinGW.
5) Go to the Qt MySQL plugin source directory:
# cd <path_where_qt_is_installed>\src\plugins\sqldrivers\mysql
6) Launch qmake to generate the Makefile
# qmake -o Makefile
"INCLUDEPATH+=<path_where_mysql_is_installed>\include"
"LIBS+=-L<path_where_mysql_is_installed>\lib\opt" mysql.pro
7) Build the plugin
# make
PS: I have tried the above for MySQL 4.1 (4.1.12a) and OpenSource Win32 Qt4.
B.
_________________________________________________________________
Free blogging with MSN Spaces http://spaces.msn.com/?mkt=nl-be
Message 5 in thread
Hi,
> The first error I got, was due to a problem in the mysql.pro file. Some
> wrong library got linked
> in. I have fixed that.
Could you post the fix you had to apply to mysql.pro? This way it will
be fixed in upcoming Qt releases.
I suspect you had to change:
win32 {
!contains(LIBS, .*pq.* ) {
LIBS *= libpq.lib
}
to:
win32 {
!contains(LIBS, .*pq.* ) {
LIBS *= -lpq
}
or something similar.
> The second problem I got, were undef symbols. However when I look into
> the mysql library, the
> symbols are there. So, I did not know what the problem was. But ...
> after some google hours I found that the mysql library was build using
> the __stdcall calling convention and this is not compatible with MinGW.
Indeed, there are different libraries for the Microsoft compiler and the
MinGW compiler. See also:
http://dev.mysql.com/doc/mysql/en/windows-client-compiling.html
http://www.dvrsol.com/programming.html#mymingw
--
[ signature omitted ]
Message 6 in thread
Hi,
>Could you post the fix you had to apply to mysql.pro? This way it will be
>fixed in upcoming Qt releases.
If you follow the steps described in the attached howto. There is no need to
change
the mysql.pro file. This is because the mysql library that will generated
using dlltool
will be called libmysql.lib.a. This name is compatible with what was in
mysql.pro file.
B.
_________________________________________________________________
Free blogging with MSN Spaces http://spaces.msn.com/?mkt=nl-be
Message 7 in thread
Hi,
> If you follow the steps described in the attached howto. There is no
It looks like the HOWTO didn't make it through.
> need to change
> the mysql.pro file. This is because the mysql library that will
> generated using dlltool
> will be called libmysql.lib.a. This name is compatible with what was in
> mysql.pro file.
The MinGW libraries are supposed to have an *.a extension as far as i
know, not *.lib.a. The MySQL page also refers to a libmysql.a library:
http://dev.mysql.com/doc/mysql/en/windows-client-compiling.html
Renaming the library may be a temporary solution, but that's really
working around the real problem.
What did you have to modify in mysql.pro?
--
[ signature omitted ]
Message 8 in thread
Hi Dimitri,
>
>What did you have to modify in mysql.pro?
>
Today, I looked into the mysql issue again and found that there is no need
to change the
mysql.pro file, because there is a contains() statement in it. This contains
statement allows
the users to pull in a different mysql client library.
Attached you can find my howto so far.
B.
--------------------------------------------------------------------------------------------------------------------------------
============================================================
Building the MySQL driver for Qt4/MinGW
============================================================
Versions used: Qt4.0.0 / MinGW 3.4.2 / MySQL 4.1
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:
# cd c:\mysql\lib\opt (c:\mysql is where our MySQL is installed)
# reimp -d libmysql.lib (reimp comes with MinGW utilities)
# dlltool --input-def ibmysql.def --dllname libmysql.dll --output-lib
libmysql.a
Now we have the MinGW compatible library called libmysql.a
2) Building the QMYSQL plugin dll.
- - - - - - - - - - - - - - - - - -
Now we can build the Qt MySQL plugin based on the above MinGW compatible
library. This can be done by taking the following steps:
# cd c:\qt\src\plugins\sqldrivers\mysql (c:\qt is where qt is installed)
# qmake -o Makefile "INCLUDEPATH+=C:\MYSQL\INCLUDE"
"LIBS+=-LC:\MYSQL\LIB\OPT -lmysql"
mysql.pro
# make (will build and install the plugin)
There is no need to change the mysql.pro file, because the -lmysql option
that is passed in the LIBS args, will disable the win32 section in the
mysql.pro.
win32 {
!contains(LIBS, .*mysql.*) { # Returns false, so libmysql.lib will
not
LIBS *= libmysql.lib # be added.
}
}
_________________________________________________________________
Free blogging with MSN Spaces http://spaces.msn.com/?mkt=nl-be
Message 9 in thread
Hi,
I successfully build and used the QMYSQL plugin for Qt.
I have extended (and fixed a typo, -k option, sorry)
in my previous HOWTO I have send.
(final HOWTO is attached)
B.
==============================================================
Building the MySQL driver for Qt4/MinGW
==============================================================
Versions used: Qt4.0.0 / MinGW 3.4.2 / MySQL 4.1
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:
# cd c:\mysql\lib\opt (c:\mysql is where our MySQL is installed)
# reimp -d libmysql.lib (reimp comes with MinGW utilities)
# dlltool -k --input-def libmysql.def --dllname libmysql.dll --output-lib
libmysql.a
Now we have the MinGW compatible library called libmysql.a
2) Building the QMYSQL plugin dll.
- - - - - - - - - - - - - - - - - -
Now we can build the Qt MySQL plugin based on the above MinGW compatible
library. This can be done by taking the following steps:
# cd c:\qt\src\plugins\sqldrivers\mysql (c:\qt is where qt is installed)
# qmake -o Makefile "INCLUDEPATH+=C:\MYSQL\INCLUDE"
"LIBS+=-LC:\MYSQL\LIB\OPT -lmysql" mysql.pro
# make (will build and install the plugin)
There is no need to change the mysql.pro file, because the -lmysql option
that is passed to the LIBS args, will disable the win32 section in the
mysql.pro
win32 {
!contains(LIBS, .*mysql.*) { # Returns false, so libmysql.lib will
not
LIBS *= libmysql.lib # be added.
}
}
3) libmysql.dll
- - - - - - - -
When you have build your qt application using the QMYSQL plugin, you have to
make
sure that libmysql.dll is in your path, or is resides next to your
executable.
Otherwise, the database open() call will fail with "Driver not loaded" in
the
SQLError return object.
_________________________________________________________________
Free blogging with MSN Spaces http://spaces.msn.com/?mkt=nl-be
Message 10 in thread
Hi,
> There is no need to change the mysql.pro file, because the -lmysql option
> that is passed to the LIBS args, will disable the win32 section in the
> mysql.pro
>
> win32 {
> !contains(LIBS, .*mysql.*) { # Returns false, so libmysql.lib
> will not
> LIBS *= libmysql.lib # be added.
> }
> }
This really is a bug. One shouldn't have to specifiy -lmysql manually.
It will hopefully be fixed in upcoming releases.
--
[ signature omitted ]
Message 11 in thread
Hello Ferenc,
first time I read your answer to Bert, I wasn't able to read the
original question - my son lazed around me - it's really hard to do
anything while that little scallywag is sitting and dancing on your
keyboard and keeps on switching your monitor on and off or even shutting
down your pc :-).
So you had compiling errors, too. Bad news.
I should hastily write a little utility app. to my company (winxp
platform, mysql database), so I was really happy when I realised qt4 Win
opensource is out, because I don't want to do it with C++Builder or
something else like delphi.
But now, after a few unsuccessful plugin compilations, to my sorrow Qt
have to be excluded from this "project". I hope TT will solve this
problem soon.
Thanks and have a good weekend!
Rudolf
P.S.:
The message subject I had found in this matter was "compilation
troubles" and can be found here:
http://lists.trolltech.com/qt-interest/2005-05/thread00463-0.html
It's really distressing that it's about qt3.3.3 and mysql 4.1.2. Maybe
is this a long-standing trouble in Qt?