Re: How to make a program look for dylibs other than /usr/local/lib?
Re: How to make a program look for dylibs other than /usr/local/lib?
- Subject: Re: How to make a program look for dylibs other than /usr/local/lib?
- From: Greg Guerin <email@hidden>
- Date: Mon, 10 Dec 2007 12:27:11 -0700
parag vibhute wrote:
>First let me explain my requirement. My requirement is to use dynamic
>library whose install name is /usr/lib/libopbx.dylib. As u know, there are
>two ways I can use this library; one as dependant library ( i.e. loading
>library when application launches - First scenario) & second as
>dynamically loaded library (i.e. loading library at runtime using dlopen
>etc. functions - Second scenario).
If you are required to use libopbx.dylib, in other words, it MUST be
present for your program to work, then why can't you just link it as a
direct dependent library? Why is it necessary to use dlopen() to link to
it at runtime?
In other words, if you always need it, why are you using dlopen(), which is
more for optional libraries than for required ones? I have a feeling
there's a requirement you haven't mentioned, or maybe there's some other
reason you're using the harder way that doesn't work (dlopen), when there's
an easier way that does (dependent library).
Another possible strategy is to wrap the libopbx.dylib's non-virtual
classes in your own virtualized wrapper library, with libopbx.dylib linked
as a dependent library of the wrapper. Then your main app would weak-link
to your virtual classes in the wrapper, and your virtualized wrapper would
"hard-link" to libopbx.dylib. This would free your main program from
direct dependence on libopbx.dylib, by moving that dependence to an
intermediary. This is essentially the Proxy design pattern.
<http://en.wikipedia.org/wiki/Proxy_design_pattern>
A proxied library has costs, but if the calls through the proxy aren't a
speed bottleneck, and the proxy isn't huge, it might work out fairly well.
>My question is there any way by which I can access month() function in
>first scenario?
For the record, I think you meant "second scenario", because the first
scenario (hard-linked to dylib) is the one that you said works. It's the
second scenario (weak-linked via dlopen), that you said doesn't work.
-- GG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden