Building cfengine with static Berkeley DB and OpenSSL libraries

It may make sense to build cfengine with Berkeley DB and OpenSSL libraries compiled-in, particularly if you do not want to install Berkeley DB and/or OpenSSL on a system in order to run cfengine.

Example:

Solaris 8 system
cfengine 2.1.22
Berkeley DB 4.5.20 static library: /usr/local/BerkeleyDB-4.5/lib/libdb-4.5.a
OpenSSL 0.9.8d static library: /usr/local/ssl/lib/libssl.a

$ gzip -cd cfengine-2.1.22.tar.gz | tar xvf -
$ cd cfengine-2.1.22
$ ./configure --with-berkeleydb=/usr/local/BerkeleyDB-4.5 --with-openssl=/usr/local/ssl
$ BERKELEY_DB_LIB="/usr/local/BerkeleyDB.4.5/lib/libdb-4.5.a -lrt" OPENSSL_LIB_LIB="/usr/local/ssl/lib/libcrypto.a -ldl" MAKE="make -e" make -e

Why -lrt?

Undefined                       first referenced
 symbol                             in file
fdatasync                           /usr/local/BerkeleyDB.4.5/lib/libdb-4.5.a(os_fsync.o)
ld: fatal: Symbol referencing errors. No output written to cfagent
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `cfagent'

Which shared libraries provide the undefined symbol fdatasync?

$ for LIB in /usr/lib/*.so; do /usr/ccs/bin/nm $LIB 2>/dev/null | grep fdatasync > /dev/null && echo $LIB; done
/usr/lib/libposix4.so
/usr/lib/librt.so

The easiest way to have the linker include this shared library is to append -lrt (-lposix4 may also work) to BERKELEY_DB_LIB.

Why -ldl?

Undefined                       first referenced
 symbol                             in file
dlerror                             /usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o)  (symbol belongs to implicit dependency /usr/lib/libdl.so.1)
dlclose                             /usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o)  (symbol belongs to implicit dependency /usr/lib/libdl.so.1)
dlopen                              /usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o)  (symbol belongs to implicit dependency /usr/lib/libdl.so.1)
dlsym                               /usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o)  (symbol belongs to implicit dependency /usr/lib/libdl.so.1)
ld: fatal: Symbol referencing errors. No output written to cfagent
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `cfagent'

Note: Solaris 9 systems appear to need -lrt and -ldl, while Solaris 10 systems only need -lrt.

More information:
Building CFEngine
static linking under solaris

Back to brandonhutchinson.com.
Last modified: 2007/03/06