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: "email@hidden" <email@hidden>
- Date: Sun, 8 Aug 2010 00:22:59 +0100
Thanks Alexander
Your reply prompted me to follow up on calling dlsym().
All is revealed below.
http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryUsageGuidelines.html
Thanks again and sorry for asking this sort of think so late at the weekend!
Regards
Jonathan Mitchell
Developer
Mugginsoft LLP
http://www.mugginsoft.com
On 8 Aug 2010, at 00:12, Alexander v. Below wrote:
> 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