All

After googling failed, I am about to give up using static QT plugin. I hope someone who had solve this problem or know quickly and can point out what I am doing wrong. Here is a bit about the background.

I am trying to use the mysql driver offer in qt 4.4.x. I can successfull compile a version of shared QT and able to use the QSqlDatabase classes to work with the database. This work perfect .

However, I would like to compile the mysql driver and plugin into my application, this open up for the need to use static mysql driver. I followed the help and ran ./configure with -static and -qt-sql-mysql -plugin-sql-mysql -I/usr/include/mysql -L/usr/lib/mysql ... and a few more switches. The result is a libsqlmysql.a in the !QT/plugins/sqldrivers/*

My project file is set up as follow:

Template = app
TARGET = executable
QT += core sql
CONFIG += static
QTPLUGIN += qsqlmysql

source += main.cpp


The source file is as follow:



#include <QtCore>
#include <QSqlDatabase>
#include <QtPlugin>

QT_IMPORT_PLUGIN( qsqlmysql )

int main( int argc, char** argv )
{
QCoreApplication app( argc, argc );

QSqlDatabase db = QSqlDatabase::addDatabase( "MYSQL" );

return 0;
}

all of this is a simple exercise to load the SQL driver.

Here is the problem .

When compiling with the QT_IMPORT_PLUGIN I have multiple problem including "undefined reference to mysql_server_end" together with many other sql_ related function .

if I take off the QT_IMPORT_PLUGIN then the it compile fine, the exec is large which suggested that it compiled the qsqlmysql static lib into it. However, at run time, it complain of no MYSQL driver loaded .

Through out googling, I see many question like this and the common solution is recompile and use it as share object. I really need to know a correct setup of static object and hope that this will be the answer for many other to come.

If you know the answer, please help, I am sure that many other are waiting for the answer as well..

OS is redhat
compiler is g++