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: "parag vibhute" <email@hidden>
- Date: Mon, 10 Dec 2007 13:14:35 +0530
Thanks for reply.
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). Now following is header file of
CTime.h which is a part of dynamic library ( which is made in C++)
class CTime
{
public:
CTime();
// get methods
long year() const;
long month() const;
long day() const;
long hour() const;
long min() const;
long sec() const;
}
Now please see that in above function declarations, "virtual keyword" is absent in function declaration. So in second scenario
i.e. in loading library at runtime using dlopen etc. functions, when I tried to use the function month() I got error as undefined symbol. So I moved to first scenario, where I was loading library at launch time of application by linking dynamic library during application compilation. Now, that error was removed. But when I tried to run the application I got error that /usr/lib/opbx.dylib is absent ( I know this is because I linked library during application compilation). So in order to overcome this error, I have only one solution
i.e. set DYLD_LIBRARY_PATH variable or place that library at default locations when dynamic loader searches.
My question is there any way by which I can access month() function in first scenario?
& Greg, compile line which I mentioned earlier was for second
scenario & sorry for mentioning void instead of long in earlier
mail.
Waiting for reply.
Thanks
Palav
On Dec 9, 2007 12:11 AM, Greg Guerin <
email@hidden> wrote:
parag vibhute wrote:
>printf("Timing=====%d\n",(*tm).month()); //header file
CTime.h
>mentions to have void month() const; method of class CTime)
If month() returns void, what could %d print?
>/usr/bin/ld: Undefined symbols:
>OPT::CTime::month() const
>
>Please note I am not dynamic library(libopbx.dylib) creator & I am
>just using it.
The error from ld suggests that libopbx.dylib is not being linked against.
This is further confirmed by the absence of
libopbx.dylib in the linkage
command-line:
>g++-4.0 -g -o test_i386 Testing.o -lstdc++ -fexception -arch i386
>-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk
In an earlier post, you said you were using dlopen() to link to
libopbx.dylib at runtime, so it seems to me that something is inconsistent
here. It may be one of the following:
1) Testing.c doesn't actually call dlopen(), nor is it linked to
libopbx.dylib at link-time, in which case ld's error message is correct.
You should link to libopbx.dylib at link-time.
2) There is no month() method that returns void, but some declaration
declares that it is, and this is causing the mangled C++ name to be
incorrect. In that case, ld is correct: there is no month() method that
returns void. You should use the correct declaration for month(), which
probably returns int or short.
3) You haven't posted enough code to determine the problem. Please post a
well-isolated and working example that shows the problem, AND does
everything you say it should do, like using dlopen() to link to
libopbx.dylib.
For the "second scenario", you will have to explain what you want, not just
what you did. We can't tell what you want to happen in the second
scenario, because you've never said exactly what you want to happen. You
describe a complicated solution that sort of works, but that is not the
same as saying what you want to happen.
For example, if you want
libopbx.dylib to remain at /usr/lib/libopbx.dylib,
you should say that. If you want it to be placed somewhere else, then say
that's what you want. If you want it relative to the program that refers
to it, then say that, and also re-read this post:
<http://lists.apple.com/archives/xcode-users/2007/Dec/msg00174.html>
-- GG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (
This email sent to
email@hidden
--
There are many things in your life that will catch your eye but only a few will catch your heart....pursue those'.
_______________________________________________
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