Chapter 8. Building and installing the BT Library

The BT library is distributed as a tar file, which contains a set of C source and header files, a Makefile and a set of testcases.

First, unpack the tar file into a convenient directory. cd to the directory containing the source files and issue the command make clean;make. This will compile each BT library file, and create the UNIX static library libbt.a in the lib sub-directory. make will also built the BT test harness bt, a utility, kcp, which performs intelligent copies of BT index files, a BTree index recovery tool btr and two additional testing utilities, bigt and bigtdel, for large file handling.

The default BT library build will create a 32-bit version, in which the maximum size of the index file is 2GiB. A version of BT with Large File Support can be built with the command make clean;make LFS=1.

When compiling programs against a LFS version of BT, if you need to manipulate the BTint value associated with a key, ensure you set the compile-time flag _FILE_OFFSET_BITS=64, e.g:

      $ gcc -o yak yak.c -Iinc -Llib -lbt -D_FILE_OFFSET_BITS=64
    

This is not necessary if you are just using the in-built data record functions (btsel etc).

In order to test the newly created BT library, you can use the bt test harness for ad-hoc testing. Alternatively, the Makefile provides a means of automated testing. make test_run will run a set of testcases, held in the Testcases sub-directory. These testcases use bt scripts to test key components of the BT library, comparing the results against known, good, output templates. The output templates distributed with BT should suffice for most standard Linux and FreeBSD builds.