Re: path to dylib
Re: path to dylib
- Subject: Re: path to dylib
- From: Miklós Fazekas <email@hidden>
- Date: Wed, 25 Feb 2004 08:58:12 +0100
We use a code like this to get the path of the .dylib
#include <mach-o/ldsyms.h>
#include <mach-o/dyld.h>
void foo ()
{
mach_header* header = 0;
header = _mh_dylib_header; /* use _mh_bundle_header if you linked
with bundle0.a and not dyld0.a */
const char* imagename = 0;
int cnt = _dyld_image_count();
for (int idx1 = 1; idx1 < cnt; idx1++) {
if (_dyld_get_image_header(idx1) == header)
imagename = _dyld_get_image_name(idx1);
}
/* your absolute path is in imagename */
}
On Feb 25, 2004, at 7:01 AM, email@hidden wrote:
> Hi
>
> is it possible to get path to dylib in runtime from within dylib's
> function?
> for example I have application foo
> dynamic library foo.dylib
>
> and function void foo(void) that I store in the foo.dylib
>
> application foo load foo.dylib and eventually will call method foo
>
> so I'd like to discover foo.dylib absolute path from within method foo
>
>
> AFAIK in Windows it's possible via DLLMain
> and GetModuleFileName
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.