PDA

View Full Version : Error building MySQL pluggin on xp with mingw32-make



weziw
22nd March 2008, 04:02
I keep getting errors trying to build the MySQL pluggin on XP. I finally found this tutorial which I followed. This is my setup
Windows XP home on compaq presario amd
MinGW 5.1.3 with the utils including reimp
mysql-5.1.23-rc-win32 installed in C:\MySQL\
Qt 4.3.4 installed in C:\Qt\4.3.4\

The instructions followed are at: http://wiki.qtcentre.org/index.php?title=Building_the_QMYSQL_plugin_on_Wind ows_using_MinGW

The error I am now getting after reinstalling both mysql and Qt:


C:\Qt\4.3.4\src\plugins\sqldrivers\mysql>mingw32-make
mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory `C:/Qt/4.3.4/src/plugins/sqldrivers/mysql'
g++ -c -O2 -Wall -fno-exceptions -fno-rtti -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_CAST_TO_ASCII -DQT_NO
_CAST_FROM_ASCII -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"..\..\..\..\
include\QtCore" -I"..\..\..\..\include\QtCore" -I"..\..\..\..\include\QtSql" -I"..\..\..\..\include\QtSql
" -I"..\..\..\..\include" -I"c:\MySQL\include" -I"c:\Qt\4.3.4\include\ActiveQt" -I"release" -I"." -I"..\.
.\..\..\mkspecs\default" -o release\main.o main.cpp
g++ -c -O2 -Wall -fno-exceptions -fno-rtti -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_CAST_TO_ASCII -DQT_NO
_CAST_FROM_ASCII -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"..\..\..\..\
include\QtCore" -I"..\..\..\..\include\QtCore" -I"..\..\..\..\include\QtSql" -I"..\..\..\..\include\QtSql
" -I"..\..\..\..\include" -I"c:\MySQL\include" -I"c:\Qt\4.3.4\include\ActiveQt" -I"release" -I"." -I"..\.
.\..\..\mkspecs\default" -o release\qsql_mysql.o ..\..\..\sql\drivers\mysql\qsql_mysql.cpp
C:/Qt/4.3.4/bin\moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -D
QT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"..\..\..\..\include\QtCore" -I"
..\..\..\..\include\QtCore" -I"..\..\..\..\include\QtSql" -I"..\..\..\..\include\QtSql" -I"..\..\..\..\in
clude" -I"c:\MySQL\include" -I"c:\Qt\4.3.4\include\ActiveQt" -I"release" -I"." -I"..\..\..\..\mkspecs\def
ault" -D__GNUC__ -DWIN32 ..\..\..\sql\drivers\mysql\qsql_mysql.h -o release\moc_qsql_mysql.cpp
g++ -c -O2 -Wall -fno-exceptions -fno-rtti -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_CAST_TO_ASCII -DQT_NO
_CAST_FROM_ASCII -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"..\..\..\..\
include\QtCore" -I"..\..\..\..\include\QtCore" -I"..\..\..\..\include\QtSql" -I"..\..\..\..\include\QtSql
" -I"..\..\..\..\include" -I"c:\MySQL\include" -I"c:\Qt\4.3.4\include\ActiveQt" -I"release" -I"." -I"..\.
.\..\..\mkspecs\default" -o release\moc_qsql_mysql.o release\moc_qsql_mysql.cpp
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -o release\qsql
mysql.lib release/main.o release/qsql_mysql.o release/moc_qsql_mysql.o -L"c:\Qt\4.3.4\lib" C:\MySQL\lib\
opt\liblibmysql.a -lQtSql4 -lQtCore4
/mingw/lib/libmingw32.a(main.o):main.c:(.text+0x104): undefined reference to `WinMain@16'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [release\qsqlmysql.lib] Error 1
mingw32-make[1]: Leaving directory `C:/Qt/4.3.4/src/plugins/sqldrivers/mysql'
mingw32-make: *** [release] Error 2

C:\Qt\4.3.4\src\plugins\sqldrivers\mysql>

Can someone help ?

jpn
24th March 2008, 12:22
Looks like it's attempting to build an application instead of a library. I suggest you restore the original mysql.pro from the source package.

weziw
25th March 2008, 02:17
Thanks for the reply Jpn. I have built driver several times and each time I did a brand new install of MySQL with the developer header files. This is the .pro files that comes with it:


TARGET = qsqlmysql

HEADERS = ../../../sql/drivers/mysql/qsql_mysql.h
SOURCES = main.cpp \
../../../sql/drivers/mysql/qsql_mysql.cpp

unix: {
isEmpty(QT_LFLAGS_MYSQL) {
!contains(LIBS, .*mysqlclient.*):!contains(LIBS, .*mysqld.*) {
use_libmysqlclient_r:LIBS *= -lmysqlclient_r
else:LIBS *= -lmysqlclient
}
} else {
LIBS *= $$QT_LFLAGS_MYSQL
QMAKE_CXXFLAGS *= $$QT_CFLAGS_MYSQL
}
}

win32:!contains(LIBS, .*mysql.*):!contains(LIBS, .*mysqld.*) {
LIBS *= -llibmysql
}

include(../qsqldriverbase.pri)


This is the main.cpp in the Qt directory


#include <qsqldriverplugin.h>
#include <qstringlist.h>
#include "../../../sql/drivers/mysql/qsql_mysql.h"

class QMYSQLDriverPlugin : public QSqlDriverPlugin
{
public:
QMYSQLDriverPlugin();

QSqlDriver* create(const QString &);
QStringList keys() const;
};

QMYSQLDriverPlugin::QMYSQLDriverPlugin()
: QSqlDriverPlugin()
{
}

QSqlDriver* QMYSQLDriverPlugin::create(const QString &name)
{
if (name == QLatin1String("QMYSQL") || name == QLatin1String("QMYSQL3")) {
QMYSQLDriver* driver = new QMYSQLDriver();
return driver;
}
return 0;
}

QStringList QMYSQLDriverPlugin::keys() const
{
QStringList l;
l << QLatin1String("QMYSQL3");
l << QLatin1String("QMYSQL");
return l;
}

Q_EXPORT_STATIC_PLUGIN(QMYSQLDriverPlugin)
Q_EXPORT_PLUGIN2(qsqlmysql, QMYSQLDriverPlugin)


I googled the error and none of the results seem to point to main.cpp rather to a linker error. I am not sure how to go on

jpn
25th March 2008, 07:44
Exactly what commands did you invoke before 'mingw32-make'?

weziw
26th March 2008, 14:36
Ok, first I went into the Qt directory and did "mingw32-make confclean".
I then reinstalled the latest MySQL with the headers to C:\MysQL.
Entered the C:\MySQL\lib\opt\ and ran the "reimp libmysql.lib" command to produce liblibmysql.a

Just a note, when I use the -d flag, I only get a libmysql.a file not a liblibmysql.a file ? Anyway I kept both in there.

Then I went into the C:Qt\4.3.4\src\plugins\sqldrivers\mysql and run the "qmake -o Makefile "INCLUDEPATH+=C:\MySQL\include" "LIBS+=C:\MySQL\lib\opt\liblibmysql.a" mysql.pro"

Then I ran the mingw32-make to build the .dll file. This command stopped due to errors, however I came across the libMySQL.dll file which I copied into C:\Qt\4.3.4\bin which is on the systems path.

I then went back into the Qt directory and did built Qt with mysql and even though building the driver failed I built Qt with the mysql configuration like this:

configure -qt-sql-mysql
mingw32-make

This time when I tried to connect to mysql using the application in the demo it actually worked. I have not had a chance to test out my own program yet.