A great feature of the Firebird database is the ability to ship an embedded database with you program. No need for a separate installation and no conflicts with other installations, just copy some files.
The embedded model is officially supported only for Windows. For this operating system everything is simple: just download the embedded server and follow the documentation.
It is possible to deploy an embedded Firebird database also under Linux, even if this is not officially documented. I started from information from Milan Babuskov, currently available here:
http://www.firebirdfaq.org/Firebird-Embedded-Linux-HOWTO.html
That page is about version 1.5: I made some simple changes and used version 2.0.x. It should also work with version 2.1.
First I downloaded the classic server (superserver does not work). For an embedded server you need to link to libfbembed.so, which contains a full server. libfbclient.so contains only the client library: it is smaller but it can only connect to a full server.
At first I linked to the files that I downloaded from the Firebird site, but I got warnings because the Firebird library used libstdc++.so.5 and my compiler used libstdc++.so.6. It turns out that Firebird is compiled with a very old compiler version for better portability.
This is not a problem when the server is used in the normal way, but it causes those warnings when I link a program to the Firebird library. I do not know if this could be a real problem, but I ended up compiling Firebird from source. It is a rather simple task (I have been able to do it!), just remember to run 'make install' to strip the resulting files. Here are some info about the compilation:
http://firebird.1100200.n4.nabble.com/Size-problem-compiling-Firebird-2-0-3-in-Linux-tt1120181.html#none
To ship an embedded Firebird database with your program you need to deploy the following files and subfolders in the folder that contains the program itself:
fulvio@fulvio-ubuntu:~/Desktop/VVV-Release-Pack$ ls --format=single-column -R
.:
firebird
firebird.conf
vvv (main program)
vvv-start.sh
./firebird:
bin
firebird.msg
intl
libfbembed.so
libfbembed.so.2
libfbembed.so.2.0.4
libicudata.so
libicudata.so.30
libicudata.so.30.0
libicui18n.so
libicui18n.so.30
libicui18n.so.30.0
libicuuc.so
libicuuc.so.30
libicuuc.so.30.0
security2.fdb
./firebird/bin:
fb_lock_mgr
gbak
isql
./firebird/intl:
fbintl
fbintl.conf
Notice that many .so files are symbolic links.
You will need to edit the firebird.conf file. Look for the line containing "RootDirectory" and change it in this way:
RootDirectory = ./firebird
Notice that lines starting with '#' are comments: you must remove that character from this line.
Now you must create a script to start your program. In the example above it is called vvv-start.sh. The file must contain the following lines:
export LD_LIBRARY_PATH=./firebird
export FIREBIRD=.
./vvv
where the last line contains the name if the program to run, in this case vvv.
Now you should be able to start your program executing the script. You cannot directly execute the program because it needs the environment variables set by the script.
Friday, June 4, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment