Re: Loading CFM shlb into a cocoa app
Re: Loading CFM shlb into a cocoa app
- Subject: Re: Loading CFM shlb into a cocoa app
- From: Douglas Davidson <email@hidden>
- Date: Thu, 5 Jul 2001 12:45:33 -0700
On Thursday, July 5, 2001, at 12:27 AM, Phil Barrett wrote:
I'm trying to load a CFM shlb (the OS X TWAIN library) using
GetSharedLibrary, which immediately crashes in CCFM_FSGetFileRef().
Str255 libName;
c2pstrcpy(libName, "TWAIN Source Manager.Shlb");
err = GetSharedLibrary(libName, kPowerPCCFragArch, kLoadCFrag,
&connection,
&addr, errMessage);
The library is in the correct location (if it isn't, GetSharedLibrary
returns with an error code).
Am I missing something? Is there an initialize call required, or maybe
there's a better way to load a shlb into a dyld app?
(I realise this is more of a Carbon question, but I'm not on that list
because I want to avoid using Carbon as much as possible!)
I don't know exactly why you're having this problem--to get a real
answer you'll probably need to ask on a Carbon list--but the Cocoaish
way to load code is through NSBundle or CFBundle. In this case, since
you're loading a non-Cocoa library, and in particular since it is CFM,
you would use CFBundle. The tricky part might be getting your shlb
inside of a bundle, but that shouldn't be impossible...note that
CFBundle automatically takes care of the simple cross-ABI issues
associated with calling CFM code from a dyld context. (More complicated
issues, like passing function pointers as arguments or return values,
are left to you.)
Douglas Davidson