Thursday, September 20, 2012

Firebird Embedded on MacOSX

Based on a document written by Fulvio, a while ago, I finally spent time writing a make file that will automatically create an embedded version of Firebird that will run on MacOSX as a bundle. All you do is make a normal build of Firebird Classic and then use this make file to create the folder which is set up in a way that allows you to access a database via isql for example without the need for a full framework. The make file detailed below was written for Firebird 2.5.x

 (updated 15th April 2014)

file embed.darwin - committed to svn B2_5_Release/builds/install/arch-specific/darwin and also to trunk
Code was added to config_root.cpp to simulate binreloc (posix) on MacOSX. Find the name of the excutable in the directory below firebird, strip the executable name, strip the lowest directory, now use the remainder to find the configuration file, firebird.conf, now read the conf file to get the actual RootDirectory for Firebird.

embed.darwin updated below, to fix a couple of other issues.

To make a Classic version of Firebird for MacOSX:
cd gen
make -B -f Makefile.install

Then you can use the following make file to create an embedded version.
copy embed.darwin from builds/install/arch-specific/darwin

make -B -f embed.darwin

# Makefile script to generate an embedded Firebird bundle from an existing Framework


    -$(RM) -rf $(FBE) ../gen/firebird/
    mkdir -p $(FBE)/Contents
    mkdir -p $(FBE)/Contents/MacOS
    mkdir -p $(FBE)/Contents/MacOS/firebird
    mkdir -p $(FBE)/Contents/Resources
    mkdir -p $(FBE)/Contents/Frameworks
    mkdir -p $(FBE)/Contents/Plugins
    mkdir -p $(FBE)/Contents/SharedSupport
    mkdir -p $(FBE)/Contents/MacOS/firebird/bin
    mkdir -p $(FBE)/Contents/MacOS/firebird/intl

    cp ../gen/install/misc/firebird.conf $(FBE)/Contents/MacOS/firebird/firebird.conf
    cp ../gen/firebird/firebird.msg $(FBE)/Contents/MacOS/firebird/firebird.msg
    cp ../gen/firebird/lib/libfbembed.dylib $(FBE)/Contents/MacOS/firebird/libfbembed.dylib
    cp ../gen/firebird/lib/libicudata.dylib $(FBE)/Contents/MacOS/firebird/libicudata.dylib
    cp ../gen/firebird/lib/libicui18n.dylib $(FBE)/Contents/MacOS/firebird/libicui18n.dylib
    cp ../gen/firebird/lib/libicuuc.dylib $(FBE)/Contents/MacOS/firebird/libicuuc.dylib
    cp ../gen/firebird/lib/libib_util.dylib $(FBE)/Contents/MacOS/firebird/libib_util.dylib
    cp ../gen/firebird/security2.fdb $(FBE)/Contents/MacOS/firebird/security2.fdb
    cp ../gen/firebird/bin/gbak $(FBE)/Contents/MacOS/firebird/bin/gbak
    cp ../gen/firebird/bin/isql $(FBE)/Contents/MacOS/firebird/bin/isql
    cp ../builds/install/misc/fbintl.conf $(FBE)/Contents/MacOS/firebird/intl/fbintl.conf
    cp ../gen/firebird/intl/libfbintl.dylib $(FBE)/Contents/MacOS/firebird/intl/fbintl.dylib
    cp ../builds/install/arch-specific/darwin/embed.Info.plist $(FBE)/Contents/Info.plist

    install_name_tool -change /Library/Frameworks/Firebird.framework/Versions/A/Firebird \
     ../libfbembed.dylib $(BINLOC)/isql
    install_name_tool -change /Library/Frameworks/Firebird.framework/Versions/A/Libraries/libicuuc.dylib \
    ../libicuuc.dylib $(BINLOC)/isql
    install_name_tool -change /Library/Frameworks/Firebird.framework/Versions/A/Libraries/libicudata.dylib \
    ../libicudata.dylib $(BINLOC)/isql
    install_name_tool -change /Library/Frameworks/Firebird.framework/Versions/A/Libraries/libicui18n.dylib \
    ../libicui18n.dylib $(BINLOC)/isql
    install_name_tool -change /Library/Frameworks/Firebird.framework/Versions/A/Firebird \
     ../libfbembed.dylib $(BINLOC)/gbak
    install_name_tool -change /Library/Frameworks/Firebird.framework/Versions/A/Libraries/libicuuc.dylib \
    ../libicuuc.dylib $(BINLOC)/gbak
    install_name_tool -change /Library/Frameworks/Firebird.framework/Versions/A/Libraries/libicudata.dylib \
    ../libicudata.dylib $(BINLOC)/gbak
    install_name_tool -change /Library/Frameworks/Firebird.framework/Versions/A/Libraries/libicui18n.dylib \
    ../libicui18n.dylib $(BINLOC)/gbak
    install_name_tool -change $(OLDPATH)/libicuuc.dylib @loader_path/libicuuc.dylib \
    install_name_tool -change $(OLDPATH)/libicudata.dylib @loader_path/libicudata.dylib \
    install_name_tool -change $(OLDPATH)/libicui18n.dylib @loader_path/libicui18n.dylib \
    install_name_tool -change $(OLDPATH)/libicudata.dylib @loader_path/libicudata.dylib \
    install_name_tool -change $(OLDPATH)/libicuuc.dylib @loader_path/libicuuc.dylib \
    install_name_tool -change $(OLDPATH)/libicudata.dylib @loader_path/libicudata.dylib \

    install_name_tool -change /Library/Frameworks/Firebird.framework/Versions/A/Libraries/libicuuc.dylib \
        @loader_path/../libicuuc.dylib $(INTLOC)/fbintl.dylib
    install_name_tool -change /Library/Frameworks/Firebird.framework/Versions/A/Libraries/libicudata.dylib \
        @loader_path/../libicudata.dylib $(INTLOC)/fbintl.dylib
    install_name_tool -change /Library/Frameworks/Firebird.framework/Versions/A/Libraries/libicui18n.dylib \
        @loader_path/../libicui18n.dylib $(INTLOC)/fbintl.dylib

    install_name_tool -id @rpath/libfbembed.dylib $(LIBLOC)/libfbembed.dylib
    install_name_tool -id @rpath/libicudata.dylib $(LIBLOC)/libicudata.dylib
    install_name_tool -id @rpath/libicui18n.dylib $(LIBLOC)/libicui18n.dylib
    install_name_tool -id @rpath/libicudata.dylib $(LIBLOC)/libicudata.dylib
    install_name_tool -id @rpath/libicuuc.dylib $(LIBLOC)/libicuuc.dylib
    install_name_tool -id @rpath/libicudata.dylib $(LIBLOC)/libicudata.dylib
    install_name_tool -id @rpath/libib_util.dylib $(LIBLOC)/libib_util.dylib

You can now tar a copy of the directory (and underlying), place anywhere on your system,
and set the RootDirectory in the firebird.conf (17th July 2013 - this now works, previously it didn't), or set the FIREBIRD environment variable to the relevant location of the firebird directory in, If your application is under launchctl, you can set the FIREBIRD variable in the Info.plist file provided and your application should run if placed in the same directory. Unfortunately OS X Mavericks does not use the environment.plist, so you need to set the environment variable using launchctl a simple script like the following should do the trick.

DIR=$(cd $(dirname "$0"); pwd)
launchctl setenv FIREBIRD $DIR/
echo setenv FIREBIRD $DIR/ | sudo tee

Should we produce a dedicated MacOSX embedded build along with the others (32bit/64bit/lipo)?

The ( can be downloaded from should anybody want it.


getmem said...

Can you please upload somewhere a working version of I can't make it to work.
Thanks in advance!

Paul Beach said...

For MacOSX? For Firebird 2.5.2? Whats the problem? Have you tried building Firebird and using the code in CVS?

getmem said...

Yes for MacOSX(Mountain Lion 10.8.4)and Firebird 2.5.2. I did exactly as you described in the blog post: I made a classic version of firebird, I downloaded embed.darwin from the SVN, then run the "make -B -f embed.darwin" command(successfully, no error message), but I'm unable to connect to the database. That's why I want to test your embeded "". Probably I'm doing something wrong. I code in Lazarus 1.0.8/FB 2.5.2, if I install firebird everything is working as it should, but I would like an embeded version(I'm new to OSX).
Thank you!

Paul Beach said...

Email me privately and I will see if I can work out whats happening.

Zabrane Mikael said...

Hi Paul,

I tried to compile Firebird- myself following the previous steps.

But got this error:
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [../gen/firebird/plugins/libfbtrace.dylib] Error 1
make[1]: *** [fbtrace] Error 2
make: *** [firebird] Error 2

The "libfbtrace.dylib" was never built that's why.

Is there any workaround?

N.B: I'm running OSX Mavericks 10.9.3, clang-503.0.40


Paul Beach said...

Re. fbtrace there is an issue with the build process for fbtrace that I haven't got around to fixing. Just cd gen and then make -B -f Makefile.fbtrace. This will force a build. Apologies

Zabrane Mikael said...

Hi Paul,

Thanks for your prompt reply.
Now I'm getting a new error related to "libicuuc.dylib".

The build script is trying to locate it under:


This error start to appear before your answer when I tried your embbeding makefile:
$ make -B -f embed.darwin

Please see below.

$ cd gen
$ make -B -f Makefile.fbtrace

g++ -bundle -flat_namespace -undefined suppress -o ../gen/firebird/plugins/libfbtrace.dylib ../temp/superclient/utilities/ntrace/TraceConfiguration.o ../temp/superclient/utilities/ntrace/traceplugin.o ../temp/superclient/utilities/ntrace/TracePluginImpl.o ../temp/superclient/utilities/ntrace/TraceUnicodeUtils.o ../temp/superclient/utilities/ntrace/PluginLogWriter.o ../temp/superclient/utilities/ntrace/platform.o ../temp/superclient/jrd/config_root.o ../temp/superclient/jrd/path_utils.o ../temp/superclient/jrd/mod_loader.o ../temp/superclient/jrd/fbsyslog.o ../temp/superclient/jrd/guid.o ../temp/superclient/jrd/os_utils.o ../temp/superclient/common/dllinst.o ../temp/superclient/jrd/isc.o ../temp/superclient/jrd/isc_file.o ../temp/superclient/jrd/isc_sync.o ../temp/superclient/jrd/CharSet.o ../temp/superclient/jrd/TextType.o ../temp/superclient/jrd/IntlUtil.o ../temp/superclient/jrd/unicode_util.o ../temp/superclient/common/classes/ClumpletReader.o ../temp/superclient/common/utils.o ../temp/superclient/config/AdminException.o ../temp/superclient/config/Args.o ../temp/superclient/config/ArgsException.o ../temp/superclient/config/ConfObj.o ../temp/superclient/config/ConfObject.o ../temp/superclient/config/ConfigFile.o ../temp/superclient/config/Configuration.o ../temp/superclient/config/Element.o ../temp/superclient/config/FileName.o ../temp/superclient/config/InputFile.o ../temp/superclient/config/InputStream.o ../temp/superclient/config/Lex.o ../temp/superclient/config/ScanDir.o ../temp/superclient/config/Stream.o ../temp/superclient/config/StreamSegment.o ../temp/superclient/vulcan/PathName.o ../temp/superclient/vulcan/RefObject.o ../temp/superclient/common/fb_exception.o ../temp/superclient/common/thd.o ../temp/superclient/common/classes/MetaName.o ../temp/superclient/common/StatusHolder.o ../temp/superclient/common/classes/init.o ../temp/superclient/common/StatusArg.o ../temp/superclient/common/classes/SafeArg.o ../temp/superclient/common/classes/MsgPrint.o ../temp/superclient/common/classes/BaseStream.o ../temp/superclient/common/classes/alloc.o ../temp/superclient/common/classes/locks.o ../temp/superclient/common/classes/semaphore.o ../temp/superclient/common/classes/fb_string.o ../temp/superclient/common/classes/timestamp.o ../temp/superclient/common/classes/PublicHandle.o ../temp/superclient/common/classes/TempFile.o ../temp/superclient/common/config/config.o ../temp/superclient/common/config/config_file.o ../temp/superclient/common/config/dir_list.o -L../gen/firebird/lib -lm -framework CoreFoundation -lcurses -lfbembed
ld: file not found: /Library/Frameworks/Firebird.framework/Versions/A/Libraries/libicuuc.dylib for architecture x86_64

Any hint please?


Paul Beach said...

Ahh yes - the other issue that needs addressing, basically its trying to link against the default framework, so let it. If you are building Classic, install 2.5.2 Classic, or SuperServer from its normal pkg and let it link against the relevant framework ICU lib. I really do need to make some time to investigate a fix for this

Zabrane Mikael said...

Me again ;-)

Paul, you sure about this line in "embed.darwin":

cp ../builds/install/arch-specific/darwin/embed.Info.plist $(FBE)/Contents/Info.plist

There's no such file called "embed.Info.plist.

What i found so far are these:

Which one should I use please?

Paul Beach said...

The file(s) specific to the embedded build were added to SVN after the last 2.5.2 Release. So if you want them, you need to get them from the B2_5_Release branch on Sourceforge. Though to be hosest the latest versions of MacOSX do not use info.plists anymore. So you can happily comment out that line.

Zabrane Mikael said...

Great. That's what I came up with.
Thx again Paul.

Unknown said...


I tried building an embedded firebird 2.5.2 classic from the B2_5_Release branch.


I got quite far, but the compiler failed with the following error.

../src/common/fb_exception.cpp:453:8: error: thread-local storage is unsupported for the current target
static TLS_DECLARE(sigjmp_buf*, sigjmp_ptr);

I have the latest XCode tools installed and run OSX 10.9.5.

Any suggestions on how to fix this build?

Thanks in Advance,

Rudie Ekkelenkamp

Paul Beach said...

The compile error "../src/common/fb_exception.cpp:453:8: error: thread-local storage is unsupported for the current target
static TLS_DECLARE(sigjmp_buf*, sigjmp_ptr);"
refers to the fact that 10.6 of OSX doesn't support Thread Local Storage under the latest versions of XCode (Clang not gcc). To correct the problem, edit prefix.darwin_x86_64 in builds/posix and change MACOSX_DEPLOYMENT_TARGET to 10.7 and also -macosx-version-min. You should also need to do the same to mh-darwin in extern/icu/source/config.

Unknown said...

Hi Paul,

Thanks for your response. That makes sense. I'll give it a try.

One more question. Do you know if there is a version of the jaybird JDBC driver available for OSX? I'm trying to integrate an embedded Firebase into a Java application and want to use the jaybird jdbc library. There only seems to be a windows and linux version.

Thanks for your help.


Paul Beach said...

It should work, currently Firebird 3.0 is building using the latest version of XCode (Clang), and that was one of the changes I had to make to the build to get it to work.

Paul Beach said...

I asked Mark Rotteveel (the current maintainer for Jaybird) about your question. Here is his answer:

"Jaybird itself will work on any OS that has Java available,
however to use Firebird embedded from Jaybird you need the JNI layer that accesses
fbembed.dll/ This layer is a jaybird22.dll,
jaybird22_x64.dll, or As I don't have a Mac, I only include a compiled version for windows and linux in the default distribution.

If people need it for a different OS (or if the compiled library doesn't work due to ABI incompatibilities), then they need to compile it themselves. They either need to download the source (in the tar.gz, eg for
) or get it from the subversion tag of the release.

They will need a C++ compiler (eg gcc), an installed JDK (which is set in the JAVA_HOME environment variable) for running ant and access to the JNI headers, and they will also need libstdc++ and libdl (or the MacOS X equivalent). It may be necessary to tweak the build-native.xml file for specific config properties (eg current config defaults to gcc, specific
search locations for - for example - the JNI headers), and to address other compilation related problems.

Compiling would then require executing:

./ compile-native

Which will create the library in


However as I don't have a Mac, I can't be sure if this is complete and if it works out of the box.

Note that for Jaybird 3 I am currently working on removing the need for this libjaybird*.so layer."

Unknown said...

Thanks a lot for the great information!

I'll try building the native version of jaybird on my mac. I'll let you know my progress.


Unknown said...

Hi Paul,

I succeeded in building the embedded firebase version for OSX. Following the different steps as described in this blog will result in a succesfull built. There was only one thing I had to change:
The compiler flag -fno-weak wasn't recognized:

clang: error: unknown argument: '-fno-weak'

It is specified in the CXXFLAGS:

CXXFLAGS:=$(CXXFLAGS) -fvisibility-inlines-hidden -fvisibility=hidden -fno-weak

After removing it, the built will be succesfull. I'm not sure if this has any major impact on the compiled code.

As far as Jaybird is concerned, that succeeded as well. There was one change in the source I had to make.

In platform.h the following include was used:


After changing it into:


the build was succesfull as well.

Thanks for all the support!

Unknown said...

For those interested in a log to build the embedded firebird on OSX, here the steps I took to get a succesfull build:

build embedded firebird on mac osx 10.9.5

checkout the branch:

svn checkout svn://

export LIBTOOLIZE=glibtoolize


edit prefix.darwin_x86_64 in builds/posix and change MACOSX_DEPLOYMENT_TARGET to 10.7
and also -macosx-version-min.
You should also need to do the same to mh-darwin in extern/icu/source/config.


clang: error: unknown argument: '-fno-weak'

The flag is specified in gen/make.platform:

CXXFLAGS:=$(CXXFLAGS) -fvisibility-inlines-hidden -fvisibility=hidden -fno-weak

Remove the -fno-weak argument.

Now make will compile, but fail on.

cp: ../gen/firebird/plugins/libfbtrace.dylib: No such file or directory
make[1]: *** [darwin_finish_cs_framework] Error 1

De libfbtrace library wasn't built. Do it manually:

cd gen
make -B -f Makefile.fbtrace

cd ..

Build Successful!!

Now build the embedded version:

cd gen

make -B -f Makefile.install

cp ../builds/install/arch-specific/darwin/embed.darwin .

make -B -f embed.darwin

Hamish said...

I used to have Firebird embedded into our app as described, but as there's a mix of binaries and resource files in the MacOS/Contents directory of the application, this won't sign and run properly with the OSX 10.9.5/10.10 GateKeeper / v2 signature changes. There shouldn't be resource files in the code directories and vice versa.

I rearranged the files by hand into a valid Firebird.framework, which is probably close to the original framework anyway. Here's the layout

total 16
lrwxr-xr-x 1 hamish staff 26 29 Oct 11:47 Resources -> Versions/Current/Resources
drwxr-xr-x 4 hamish staff 136 29 Oct 11:46 Versions
lrwxr-xr-x 1 hamish staff 33 29 Oct 11:47 libfbembed.dylib -> Versions/Current/libfbembed.dylib

total 8
drwxr-xr-x 10 hamish staff 340 29 Oct 11:47 A
lrwxr-xr-x 1 hamish staff 1 29 Oct 11:46 Current -> A

total 21888
drwxr-xr-x 3 hamish staff 102 29 Oct 11:46 Libraries
drwxr-xr-x 8 hamish staff 272 29 Oct 11:46 Resources
-rwxr-xr-x 1 hamish staff 1015600 29 Oct 11:47 fbintl
-rwxr-xr-x 1 hamish staff 7159364 29 Oct 11:47 libfbembed.dylib
-rwxr-xr-x 1 hamish staff 8440 29 Oct 11:47 libib_util.dylib
-rwxr-xr-x 1 hamish staff 1556564 29 Oct 11:46 libicudata.dylib
-rwxr-xr-x 1 hamish staff 545084 29 Oct 11:46 libicui18n.dylib
-rwxr-xr-x 1 hamish staff 907156 29 Oct 11:47 libicuuc.dylib

total 8
lrwxr-xr-x 1 hamish staff 19 29 Oct 11:46 libib_util.dylib -> ../libib_util.dylib

total 1784
-rw-r--r-- 1 hamish staff 569 29 Oct 11:46 Info.plist
-rw-r--r-- 1 hamish staff 26825 29 Oct 11:46 firebird.conf
-rw-r--r-- 1 hamish staff 149012 29 Oct 11:46 firebird.msg
drwxr-xr-x 4 hamish staff 136 29 Oct 11:46 intl
drwxr-xr-x 3 hamish staff 102 29 Oct 11:46 lib
-rw-r--r-- 1 hamish staff 729088 29 Oct 11:46 security2.fdb

total 24
lrwxr-xr-x 1 hamish staff 12 29 Oct 11:46 fbintl -> ../../fbintl
-rw-r--r-- 1 hamish staff 6381 29 Oct 11:46 fbintl.conf

total 8
lrwxr-xr-x 1 hamish staff 22 29 Oct 11:46 libib_util.dylib -> ../../libib_util.dylib

Nils said...

Hi thx for your blog post, I tried out the instructions posted, but still got a linker error in the end. I am on Yosemite with the latest dev tools and with


12 warnings generated.
g++ ../temp/boot/jrd/dsc.o ../temp/boot/jrd/gds.o ../temp/boot/jrd/isc.o ../temp/boot/gpre/cmd.o ../temp/boot/gpre/cme.o ../temp/boot/gpre/cmp.o ../temp/boot/gpre/c_cxx.o ../temp/boot/gpre/exp.o ../temp/boot/gpre/gpre.o ../temp/boot/gpre/hsh.o ../temp/boot/gpre/int_cxx.o ../temp/boot/gpre/jrdmet.o ../temp/boot/gpre/movg.o ../temp/boot/gpre/msc.o ../temp/boot/gpre/par.o ../temp/boot/gpre/pat.o ../temp/boot/gpre/sqe.o ../temp/boot/gpre/sql.o ../temp/boot/gpre/pretty.o ../temp/boot/gpre/gpre_meta_boot.o ../temp/boot/jrd/config_root.o ../temp/boot/jrd/path_utils.o ../temp/boot/jrd/mod_loader.o ../temp/boot/jrd/guid.o ../temp/boot/jrd/os_utils.o ../temp/boot/common/dllinst.o ../temp/boot/common/fb_exception.o ../temp/boot/common/thd.o ../temp/boot/common/classes/MetaName.o ../temp/boot/common/StatusHolder.o ../temp/boot/common/classes/init.o ../temp/boot/common/StatusArg.o ../temp/boot/jrd/fbsyslog.o ../temp/boot/common/utils.o ../temp/boot/common/config/config.o ../temp/boot/common/config/config_file.o ../temp/boot/common/config/dir_list.o ../temp/boot/common/classes/alloc.o ../temp/boot/common/classes/locks.o ../temp/boot/common/classes/semaphore.o ../temp/boot/common/classes/fb_string.o ../temp/boot/common/classes/timestamp.o ../temp/boot/common/classes/PublicHandle.o ../temp/boot/common/classes/TempFile.o ../temp/boot/common/classes/SafeArg.o ../temp/boot/common/classes/MsgPrint.o ../temp/boot/common/classes/BaseStream.o ../temp/boot/common/cvt.o -o ../gen/firebird/bin/gpre_boot -L../gen/firebird/lib -lm -framework CoreFoundation -lcurses
Undefined symbols for architecture x86_64:
"std::bad_alloc::bad_alloc()", referenced from:
Firebird::BadAlloc::BadAlloc() in fb_exception.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [../gen/firebird/bin/gpre_boot] Error 1
make[2]: *** [gpre_boot] Error 2
make[1]: *** [../gen/firebird/bin/gpre_static] Error 2
make: *** [firebird] Error 2

Paul Beach said...


Email me privately, I recently upgraded to Yosemite to fix an issue with SuperServer startup and I have 2.5.3 building on Yosemite. I guess you probably need my copy of prefix.darwin_x86_64 and darwin.defaults.