Firebird embedded on
Linux HOWTO

I've found two guides [1][2] on
the Internet, but they were brief and left
some questions open. They also assume you know how to work with
full Firebird server version. I decided to write one for complete
beginners
who don't have much Firebird knowledge.

Important: This HOWTO is meant for
machines that don't even have Firebird installed. If you do have
Firebird installed, you probably won't have to go through all these
steps. You also don't need to have access to root account.

Step 1: download the
Classic Server .tar.gz package

Firebird comes in two flavors: Super Server and Classic Server. Classic
server can be used as embedded.
This HOWTO is created while using ClassicServer version 1.5.3.
There are .rpm and .tar.gz binary packages. Download the .tar.gz as it
is easier to unpack

Step 2: unpack it and
copy files

Inside the FirebirdCS-1.5.3.4870.i686.tar.gz file, you'll find
buildroot.tar.gz file which you need to unpack as well. Now, go
to
directory opt/firebird in unpacked archive and copy the
following files
to some folder of your choice. This is the folder from which your app.
will be run. Let's assume it's /home/milanb/fbembed. Also
create
subdirectories bin and intl for files that go there:

It is normal to get that error on the first run. The trick is to simply
log out, and lock manager would happily run under your username (milanb
in my case). You can check that with ps auxw | grep fb_lock_mgr.
Now we connect back to the database:

Well, that's about it. Everything is setup and now you should put your
executable into this directory and run it.

Step 4: compiling a
test IBPP application

You can download IBPP library from www.ibpp.org. Only source version is
available, and that is exactly what we need. I took
ibpp-2.5.2.2-src.zip. Unpack the file (be careful, there are few files
that unpack into current directory). We only need files from core
directory. Create directory ibpp inside fbembed and
copy the files from core there. In my example I have
/home/milanb/fbembed/ibpp. Take a look at final directory structure to get
the idea.

Now we'll write a simple program that connects to that test.fdb
database we created in step 3, insert some values into table table1,
and read them back.

Of course, for your application with many source files, you'll create a
makefile. In that makefile, you need to add ibpp/all_in_one.cpp
to your source files, and -lfbembed to linker flags. In order
to find libfbembed, linker needs to look into directory with that .so
file, so you need to give -L/home/milanb/fbembed or whatever is
the path on your system (I used -L. in the above example, which means
to look in current directory, but that is bad idea for makefiles which
might change the current working directory). IBPP_LINUX has to be
defined for all files that include ibpp.h, so you best add -DIBPP_LINUX
to compiler options.

Final notes

As you can see, it's quite possible to create, develop and run an
application that uses embedded Firebird on Linux, without having
access to root account or having full Firebird package installed.
However, quick development assumes that you have administration tool
concurrently accessing the database with application (you change things
in admin. tool and observe have application behaves, or you monitor
what is application doing). So I recommend that you install the full
Firebird server for development, and only use embedded variant when you
deploy the application. As for administration tools, if you are a Linux
user (as is assumed audience of this HOWTO) you should look
into FlameRobin.

If you have problems with this setup or you have questions about
Firebird usage, please join the firebird-support
mailing list. I read it on a daily basis (except when on vacation), and
there are many others who are very helpful.