Re: Dynamic loading of a third party .dylib
Re: Dynamic loading of a third party .dylib
- Subject: Re: Dynamic loading of a third party .dylib
- From: "Alexander v. Below" <email@hidden>
- Date: Sun, 08 Aug 2010 01:12:30 +0200
I am using a library in a similar fashion (I am loading a jnilib in a Cocoa App), and I am calling dlsym to resolve the individual function addresses.
Alex
Am 08.08.2010 um 00:48 schrieb email@hidden:
>
> My Cocoa app would very much like to link to a third party dylib.
>
> The dylib is created using an external make file and I don't really want to start modifying the build script to change the deployment INSTALL_PATH.
>
> I know that I can wield install_name_tool in a build phase but I thought about using dlopen().
> I know where my dylib is in my bundle so I can target it okay.
>
> 1. In Xcode I link to my dylib and mark it as weak.
> 2. In my app I call dlopen() before accessing any of the library symbols.
>
> But the symbol doesn't get resolved.
>
> The crash log reports:
>
> Dyld Error Message:
> can't resolve symbol _G__main in /Nuzzle/And/Scratch/MacOS/Contents/boo because dependent dylib #5 could not be loaded
>
> Do I have to manually call dlsym() or am I missing a weak attribute somewhere?
>
> Or am I just lost in the weeds.
>
> some code:
>
> NSString *dylibPath = [path stringByAppendingPathComponent:@"lib/libCint.dylib"];
> const char *libPath = [dylibPath cStringUsingEncoding:NSUTF8StringEncoding];
> void *dl = dlopen(libPath, RTLD_NOW);
> const char *dlErr = dlerror();
> if (dlErr) {
> NSLog(@"dlerror() = %s", dlErr);
> } else {
> NSLog(@"dylib path is %s, dl = %p", libPath, dl);
> }
> G__main(0, NULL); // in libCint.dylib
>
> Regards
>
> Jonathan Mitchell
>
> Developer
> Mugginsoft LLP
> http://www.mugginsoft.com
>
> _______________________________________________
> 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
_______________________________________________
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