Loading libdbi at runtime

Database Independent Abstraction Layer for C: libdbi Programmer's Guide
Prev | Chapter 2. libdbi in a Nutshell (Quickstart Guide) | Next

# 2.3. Loading libdbi at runtime

The generic example shown in the previous section assumed that the program is linked against libdbi. This is in fact the recommended way to add libdbi functionality to your programs. However, there are situations where this approach will not work. Some programs are designed to load modules at runtime to extend their capabilities. A well-known example is the web server Apache, which uses loadable modules to custom-tailor its capabilities. If such a module were to use libdbi, we'd look at the following pattern:

Parent => dl_open(module) => dl_open(driver)

The dynamically loaded module is linked against libdbi whereas the parent application is not. For this pattern to work, the drivers are linked against libdbi by default. This avoids "undefined symbol" errors at runtime, but may cause problems under arcane conditions or on equally arcane operating systems. If you should ever encounter such problems, you can switch off linking the drivers against libdbi like this:

    ~/libdbi-drivers #./configure --disable-libdbi --with-mysql

Prev | Home | Next
Generic Example Program | Up | Adding libdbi to your project