|
![]() ![]() ![]() |
Building and Using Berkeley DB XML Applications on UNIX
Any application which uses Berkeley DB XML, regardless of language API used, relies on four libraries: Berkeley DB XML, Berkeley DB, XQilla and Xerces C++. When compiling, the include files from these packages must be available, and the libraries must be included when linking the application.
When running an application, each of the shared libraries must be located by the dynamic linker, usually controlled by system settings and the LD_LIBRARY_PATH environment variable. This applies to both C++ and Java applications. See Dynamic shared libraries for more information
Building C++ ApplicationsAssuming Berkeley DB XML, Berkeley DB, Xerces C++ and XQilla have all been built using buildall.sh and installed in the default location, a typical command to compile C++ code that uses Berkeley DB XML is:
g++ -c -Ipath_to_distribution/install/include -c myapp.cpp
If the libraries are in different locations, such as Xerces and XQilla in /usr/local, Berkeley DB in /usr/local/BerkeleyDB.4.8, and Berkeley DB XML in /usr/local/BerkeleyDBXML.2.5, a command might be:
g++ -c -I/usr/local/include -I/usr/local/BerkeleyDBXML.2.5/include -I/usr/local/BerkeleyDB.4.8/include -c myapp.cpp
Then, corresponding link commands are:
g++ -o myapp myapp.o -Lpath_to_distribution/install/lib -lxqilla -lxerces-c -ldbxml-2.5 -ldb_cxx-4.8
and
g++ -o myapp myapp.o -L/usr/local/lib -L/usr/local/BerkeleyDBXML.2.5/lib -L/usr/local/BerkeleyDB.4.8/lib -lxqilla -l xerces-c -ldbxml-2.5 -ldb_cxx-4.8
Note the use of -ldb_cxx-4.8 and not -ldb-4.8. Berkeley DB XML uses the Berkeley DB C++ API internally, so the link step will fail if the wrong library is used.
Building Java ApplicationsJava applications compile normally using javac and require both db.jar and dbxml.jar in their CLASSPATH. Assuming buildall.sh and default installation directories were used these reside in the directory path_to_distribution/install/lib. This is a reasonable javac line:
In order to run the resulting program both CLASSPATH and LD_LIBRARY_PATH (or equivalent) must be set properly, e.g.javac -cp"path_to_distribution/install/lib/db.jar:path_to_distribution/install/lib/dbxml.jar" MyClass.java
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:path_to_distribution/install/lib export CLASSPATH=$CLASSPATH:path_to_distribution/install/lib/db.jar:path_to_distribution/install/lib/dbxml.jar java MyClass
![]() ![]() ![]() |
Copyright (c) 1996-2009 Oracle. All rights reserved.