Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!dtgcube!ed From: ed@DTG.COM (Edward Jung) Newsgroups: comp.sys.next Subject: Re: Lisp <-> Objective C Message-ID: <1989Dec8.220555.3912@uunet!dtgcube> Date: 8 Dec 89 22:05:55 GMT References: <11996@phoenix.Princeton.EDU> Sender: ed@uunet!dtgcube (Edward Jung) Reply-To: ed@DTG.COM (Edward Jung) Distribution: na Organization: The Deep Thought Group, L.P. Lines: 44 In-Reply-To: djlinse@phoenix.Princeton.EDU (Dennis Linse) In article <11996@phoenix.Princeton.EDU>, djlinse@phoenix (Dennis Linse) writes: > >An associate is trying to use the Allegro Common Lisp - Objective C >interface provided on the NeXT. Nearly everything works fine, except >(you knew that was coming) when trying to access an objective-c class [code deleted] > >Included in SimulatorApp.m is a call to Expert (i.e. [Expert new]). >When this is loaded into Lisp, the class is created and printed out just >fine. The loading of the .o file begins, but then fails with an error >something like "Symbol .objc_class_name_Expert undefined". He was only >able to get this far by creating an .h file with an @interface to a >dummy Expert class. I can see how this is incorrect, but I can't find >any other way to fix it. What appears to be needed is an extern >declaration for the class, so that the Objective-C can be compiled >(without the dummy @interface, it won't even compile because Expert is >unknown). The "[Expert new]" is compiled into code that looks for an Objective-C symbol for Expert, that is, ".objc_class_name_Expert". Since that is not in the image, the link fails. You should use the following instead: #import [objc_getClass("Expert") new]; Alternatively, you can "cache" the class (factory) object: id Expert; Expert = objc_getClass("Expert"); my_expert = [Expert new]; Both examples insure that the symbol is extracted from the run-time image rather than the compiled (static) information. -- Edward Jung The Deep Thought Group, L.P. BIX: ejung 3400 Swede Hill Road NeXT or UNIX mail Clinton, WA. 98236 UUCP: uunet!dtgcube!ed Internet: ed@dtg.com