From owner-freebsd-questions@FreeBSD.ORG Thu Nov 13 00:09:50 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8A5E51065680 for ; Thu, 13 Nov 2008 00:09:50 +0000 (UTC) (envelope-from markus.hoenicka@mhoenicka.de) Received: from smtprelay11.ispgateway.de (smtprelay11.ispgateway.de [80.67.29.28]) by mx1.freebsd.org (Postfix) with ESMTP id 452418FC18 for ; Thu, 13 Nov 2008 00:09:50 +0000 (UTC) (envelope-from markus.hoenicka@mhoenicka.de) Received: from [92.229.83.125] (helo=yeti.mininet) by smtprelay11.ispgateway.de with esmtpa (Exim 4.68) (envelope-from ) id 1L0PYn-0004VV-Iw for freebsd-questions@freebsd.org; Thu, 13 Nov 2008 00:55:45 +0100 X-Mailer: emacs 22.1.1 (via feedmail 8 I); VM 7.19 under Emacs 22.1.1 From: "Markus Hoenicka" MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <18715.28127.306511.577084@yeti.mininet> Date: Thu, 13 Nov 2008 00:59:27 +0100 To: freebsd-questions@freebsd.org X-Df-Sender: 472582 Subject: dlsym can't use handle returned by dlopen? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Nov 2008 00:09:50 -0000 Hi, FreeBSD yeti.mininet 6.1-RELEASE FreeBSD 6.1-RELEASE #1: Mon Aug 28 22:24:48 CEST 2006 markus@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. regards, Markus -- Markus Hoenicka markus.hoenicka@cats.de (Spam-protected email: replace the quadrupeds with "mhoenicka") http://www.mhoenicka.de