dlsym can't use handle returned by dlopen?

Markus Hoenicka markus.hoenicka at mhoenicka.de
Wed Nov 12 16:09:50 PST 2008


FreeBSD yeti.mininet 6.1-RELEASE FreeBSD 6.1-RELEASE #1: Mon Aug 28 22:24:48 CEST 2006     markus at yeti.mininet:/usr/src/sys/i386/compile/YETI  i386

I'm trying to do the following: libdbi (http://libdbi.sourceforge.net)
is a database abstraction layer which is linked as a shared object
into applications. The libdbi library uses dlopen() to load database
drivers which in turn are linked against database client
libraries. Now I want to access functions defined in the database
client library from within the libdbi library. In brief, I thought
this is going to work like this:

dlhandle = dlopen("path", RTLD_NOW);
function_pointer = dlsym(dlhandle, "function_name");

dlhandle is not NULL and does not crash the app when passed to
dlclose(), so I assume the handle is valid. Accessing the functions
does work on most systems (Linux, OSX, Cygwin, to name a few), but I
get "Undefined symbol" errors on FreeBSD. Interestingly, the following
does work:

function_pointer = dlsym(RTLD_DEFAULT, "function_name");

Why is that? Or rather: what am I doing wrong?

Any help is appreciated.


Markus Hoenicka
markus.hoenicka at cats.de
(Spam-protected email: replace the quadrupeds with "mhoenicka")

More information about the freebsd-questions mailing list