Re: Obj-C in a dylib
Re: Obj-C in a dylib
- Subject: Re: Obj-C in a dylib
- From: "Thomas L. Davis" <email@hidden>
- Date: Mon, 3 May 2004 17:46:49 -0500
Actually, I found a fifth way. The MATLAB external API provides a call
to lock a MEX-file so that it can't be cleared from memory. I feel
pretty dumb not finding this earlier.
Tom
On May 3, 2004, at 12:01 PM, Bob Ippolito wrote:
On May 3, 2004, at 11:20 AM, Thomas L. Davis wrote:
I'm trying to build a MATLAB MEX-file (a dylib I think) that uses the
MacOS X Foundation, CoreFoundation and IOKit frameworks. The MEX-file
builds and (mostly) works okay. But I get a crash when the MEX-file
is cleared:
It's not a dylib, a bundle (MH_BUNDLE). MH_DYLIB isn't unloadable at
all, whether or not you are using ObjC, and they are loaded with a
different API (or automatically by the runtime linker).
I think the basic problem is that MATLAB doesn't use the Obj-C
runtime but my MEX-file does. Evidently the runtime does not like to
be unlinked by NSUnLinkModule.
Is there a solution to this problem?
Several, none of them good, but here are a few off the top of my head.
- Don't use clear
- Don't use Obj C
- Make your MEX file load all of its Obj C functionality at runtime
from a second bundle or dylib which you do not unload
- Do an evil runtime hack to replace the current implementation of
NSUnLinkModule with something else that'll do a no-op if there if ObjC
code in there (you'll probably want to read through the darwin source
code for the ObjC runtime and dyld in this case).
-bob
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.