Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Problem using dlopen



OK, think I've found my problem, but the solution is a little strange
to me.  Can't imagine this hasn't occured before, if this is the
actual problem.

1 When dlopen loads the library, it loads find.  In the startup of the
library however, a call is made to a function that calls nsdispatch.

At line 319 of the function, a call is made to dlopen to load the
files (one by one) from nsswitch.conf.  Those calls all fail, as there
are no libraries to load (being all internal).
At this point, there is an error code stored by the loader saying that
it can't find the library (in my case "nss_dns.so.0").  That error
code is not cleared before exiting the nsdispatch routine, so of
course, it still exists when dlopen returns.

Seems to me, the fix is to make a call to dlerror() at line 328, right
before the "goto out" line.

Does this make sense?  What do I do next if it is?

David

On 1/6/09, David Dudley <dldudley%gmail.com@localhost> wrote:
> Scanned all the source files for occurrences of 'dlopen', and blocked
> each with print statements before and after.
>
> No reference to the "nss_dns.so.0" exists.
>
> Here is the ldd list:
> --------------------------------------
> ldd /usr/local/EPICS/lib/netbsd-x86/libEpics.so
> /usr/local/EPICS/lib/netbsd-x86/libEpics.so:
>         -lc.12 => /usr/lib/libc.so.12
>         -lXdmcp.6 => /usr/X11R7/lib/libXdmcp.so.6
>         -lXau.6 => /usr/X11R7/lib/libXau.so.6
>         -lX11.6 => /usr/X11R7/lib/libX11.so.6
>         -lICE.6 => /usr/X11R7/lib/libICE.so.6
>         -lSM.6 => /usr/X11R7/lib/libSM.so.6
>         -lXt.6 => /usr/X11R7/lib/libXt.so.6
>         -lXext.6 => /usr/X11R7/lib/libXext.so.6
>         -lXmu.6 => /usr/X11R7/lib/libXmu.so.6
>         -lXp.6 => /usr/X11R7/lib/libXp.so.6
>         -lexpat.1 => /usr/X11R7/lib/libexpat.so.1
>         -lz.1 => /usr/lib/libz.so.1
>         -lfreetype.6 => /usr/X11R7/lib/libfreetype.so.6
>         -lfontconfig.1 => /usr/X11R7/lib/libfontconfig.so.1
>         -lXrender.1 => /usr/X11R7/lib/libXrender.so.1
>         -lXrandr.2 => /usr/X11R7/lib/libXrandr.so.2
>         -lXft.2 => /usr/X11R7/lib/libXft.so.2
>         -lXm.0 => /usr/pkg/lib/libXm.so.0
>         -lXtst.6 => /usr/X11R7/lib/libXtst.so.6
>         -lposix.0 => /usr/lib/libposix.so.0
>         -lpthread.0 => /usr/lib/libpthread.so.0
>         -ltermcap.0 => /usr/lib/libtermcap.so.0
>         -lreadline.5 => /usr/pkg/lib/libreadline.so.5
>         -lcurses.6 => /usr/lib/libcurses.so.6
>         -lstdc++.6 => /usr/lib/libstdc++.so.6
>         -lm.0 => /usr/lib/libm387.so.0
>         -lm.0 => /usr/lib/libm.so.0
>         -lgcc_s.1 => /usr/lib/libgcc_s.so.1
>         -l114135a4-6f6c-11d3-95bc-00104b8742df =>
> /usr/local/EPICS/lib/netbsd-x86/lib114135a4-6f6c-11d3-95bc-00104b8742df.so
>         -lCom => /usr/local/EPICS/lib/netbsd-x86/libCom.so
>         -lca => /usr/local/EPICS/lib/netbsd-x86/libca.so
>         -lcfcaa62e-8199-11d3-a77f-00104b8742df =>
> /usr/local/EPICS/lib/netbsd-x86/libcfcaa62e-8199-11d3-a77f-00104b8742df.so
>
> --------------------------------------
>
> I went through all the libraries in /usr/local/EPICS/lib/netbsd-x86,
> and none of them reference a library by that name.
>
> This program runs great on OpenSolaris, Linux, Apple OSx, and several
> other flavors of Unix.  I'm trying to port it to Net, but not having
> success on this single problem.
>
> David
>
> On 1/4/09, Kun Niu <haoniukun%gmail.com@localhost> wrote:
>> You can try to use the ldd utility to figure out if it depends on the
>> specified so library file.
>>
>> 2009/1/5 Daniel Carosone <dan%geek.com.au@localhost>
>>
>>> On Sun, Jan 04, 2009 at 09:37:02PM -0600, David Dudley wrote:
>>> > I have a library that won't load with dlopen.  Even worse, when
>>> > dlerror is called, it returns the wrong library name.
>>> >
>>> > The library is named
>>> > /usr/local/EPICS/lib/netbsd-x86/libEpics.so,
>>> >
>>> > I surrounded the call with print statements so I could capture it,
>>> > I get
>>> > -------------------------------------------------
>>> > Doing dlopen on /usr/local/EPICS/lib/netbsd-x86/libEpics.so
>>> > Back from dlopen
>>> > Got error
>>> > Shared object "nss_dns.so.0" not found
>>> > -------------------------------------------------
>>> > This is all in a single thread, inline.
>>>
>>>
>>> I guess your libEpics.so is itself marked as being dependent on
>>> nss_dns.so.0, and this is not being satisfied.  Perhaps the link
>>> invocation for building libEpics should be investigated.
>>>
>>> --
>>> Dan.
>>>
>>
>>
>>
>> --
>>         牛坤
>> MSN:haoniukun%hotmail.com@localhost <MSN%3Ahaoniukun%hotmail.com@localhost>
>>
>



Home | Main Index | Thread Index | Old Index