Wednesday, August 18, 2010

Building the Qt FireBird SQL driver

The Qt toolkit contains many great SQL drivers and among them is also an InterBase / FireBird SQL driver. But the Windows version of the toolkit ships with SQLite and ODBC driver binaries only. The other ones have to be built by ourseleves. This article describes how to build the FireBird driver using MinGW 32bit version of Qt 4.6 for Windows.

The directory QT means the installation directory of Qt SDK (mine is e.g. c:\qt\2010.04).

Download the binary distribution of Firebird for Windows. Take the include directory, rename it (e.g. firebird) a put it into QT\qt\include. I like to do it in order not to mix the header files of other projects with Qt headers accidentally. Take the DLLs (fbclient.dll is enough) and put it into QT\qt\bin. Take the LIBs (fbclient_ms.lib is enough) and put it anywhere (QT\qt\lib is fine but it does not matter since we will need to supply the full path anyway). Rename it to fbclient.lib so that the name is the same as the DLL (this may not be neccessary but just in case).

Open the project of ibase driver in QtCreator (QT\src\plugins\sqldrivers\ibase\ Do not copy the project outside the Qt sources directory, there are some inter-dependencies. Open it where it is. Open the header file qsql_ibase.h and change the path to firebird header files (which we have put in a separate directory) like this

#include <firebird/ibase.h>

Open the project file, comment out the settings of LIBS (unix and win32) and put there a new line:

LIBS += c:/qt/2010.03/qt/lib/fbclient.lib

The full path is needed because MinGW linker can use LIBs made with MSVC with fullpath only. On the bright side there is no need to convert the MSVC libs to other format which is a painful process that may not work.

Then build the project. The debug and release build are made at the same time and everything is copied to the right directories (QT\qt\plugins\sqldrivers) and ready to be used.


Rajiv said...

What about Linux. Any links?

Gosztola said...

Nice article, thanks.