For this you will need to have firebird development package already installed on the system and also Qt 5.3. First, we go to the plugin source location:
cd <QtPath>/5.3/Src/qtbase/src/plugins/sqldrivers/ibase
Unless we edit on he of the project includes, the build will fail, so let’s edit this. (I use joe, use whatever you like):
joe ../../../sql/drivers/ibase/qsql_ibase.pri
Once file is open for editing, find the following line:
!contains(LIBS, .*gds.*):!contains(LIBS, .*libfb.*):LIBS += -lgds
and change it to this:
!contains(LIBS, .*gds.*):!contains(LIBS, .*lfb.*):LIBS += -lgds
(the reason of changing this is that you specify later LIBS+=-lfbclient, so there will be no lib in front of fbclient)
All set, build and install:
<QtPath>/Qt/5.3/<platform>/bin/qmake "INCLUDEPATH=<firebird header files>" "LIBS+=-lfbclient" ibase.pro make make install
On my system, by default the <firebird header files> are located in the /usr/include/firebird folder.
Code to test the database connectivity:
QSqlDatabase db = QSqlDatabase::addDatabase(“QIBASE”);
db.setHostName(“your host here”);
db.setDatabaseName(“your database file (with path) here”);
db.setUserName(“your username”);
db.setPassword(“your password”);
bool ok = db.open();if (!ok) {
QSqlError err = db.lastError();
qDebug()<<“woopsie error opening database:”<<err.text();
} else {
qDebug()<<“Database successfully opened.”;
}
Happy coding.
2 Comments.