From owner-freebsd-questions@FreeBSD.ORG Tue Mar 29 21:58:32 2011 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 BF87B106564A for ; Tue, 29 Mar 2011 21:58:32 +0000 (UTC) (envelope-from stapleton.41@gmail.com) Received: from mail-vx0-f182.google.com (mail-vx0-f182.google.com [209.85.220.182]) by mx1.freebsd.org (Postfix) with ESMTP id 760388FC14 for ; Tue, 29 Mar 2011 21:58:32 +0000 (UTC) Received: by vxc34 with SMTP id 34so693552vxc.13 for ; Tue, 29 Mar 2011 14:58:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=a0OVkAyKlcQunxP7gjJU+X76MUu9+B0fRPFtsJJ1V/U=; b=pA9PeKeN668h0D9yGlHeaJbvqg8v4J2YDMdUdfSjaFt+YOG7JhDObG7X3tquOHL1Nv 8wQFQH/YQ6pPdSLdL5sh/l72yn39qyoo9YO2v3dw/gVXOpYtg3VDHIN0et3psz3PtSxZ SBuon8k0jRGG6X+sORzw1HAFba5XmKW2QqAOo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=UnDcLBGRl5+jSqXayE3VomMKJ+PQoVKEcd2X6Q7iF76gjxVoH1P0cBQm53FDCFt7jA 4qv+PgsSP+gnB0HHxHz+ZTKXvRIJZTx+U98OmxrG5i7/rvhfnNADVvKJg//bhS98X8ER oxCvCy8bTuOS8SODU9T+R5htr/8tx2IP7TAic= MIME-Version: 1.0 Received: by 10.52.18.5 with SMTP id s5mr491812vdd.156.1301435910132; Tue, 29 Mar 2011 14:58:30 -0700 (PDT) Received: by 10.52.167.167 with HTTP; Tue, 29 Mar 2011 14:58:30 -0700 (PDT) In-Reply-To: References: Date: Tue, 29 Mar 2011 21:58:30 +0000 Message-ID: From: Jim To: Giorgos Keramidas , freebsd-questions@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: Subject: Re: opening a shared object / failing with Undefined Symbol. 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: Tue, 29 Mar 2011 21:58:32 -0000 On Sat, Mar 26, 2011 at 11:31 PM, Giorgos Keramidas wrote: > On Tue, Mar 22, 2011 at 2:28 PM, Jim wrote: >> I have an application that opens two .so files with dlopen(3): >> =A0/usr/local/lib/libag_core.so >> =A0/usr/local/lib/libag_gui.so >> >> Both files exist >> Running nm(1) against each produces a lot of output, showing all the >> symbols I know to exist in each library. >> >> My application gets a null return from dlopen on the libag_gui.so. >> >> dlerror produces the following string: >> =A0"/usr/local/lib/libag_gui.so Undefined symbol "agTimingLock" >> >> $ nm /usr/local/lib/libag_gui.so | grep agTiming >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 U agTimingLock >> >> I'm guessing that means that agTimingLock is used in that library but >> not defined? >> >> $ nm /usr/local/lib/libag_core.so | grep agTiming >> 0000000000141c00 B agTimingLock >> >> And this would mean that it is defined in libag_core.so? > > Yes, but it's in the uninitialized data section: > > % man nm > ... > =A0 =A0 =A0 =A0 =A0 "B" > =A0 =A0 =A0 =A0 =A0 "b" The symbol is in the uninitialized data section (= known as BSS). > > What is the "ag" library? Which version are you using? What sort of > dlopen() call did you try to run? > The "ag" library is libagar ( http://libagar.org/ ): The code amounts to the following: void * coredl =3D dlopen("/usr/local/lib/libag_core.so", 0) void * guidl =3D dlopen("/usr/local/lib/libag_gui.so", 0) and the function: int (*AG_InitCore)(const char * title, int flags); int (*AG_InitGraphics)(const char * drv); *((void *)AG_InitCore) =3D dlsym(coredl, "AG_InitCore"); *((void *)AG_InitGraphics) =3D dlsym(guidl, "AG_InitGraphics"); The prototypes for the AG_* functions match. Thanks, -Jim Stapleton