From: not AT an DOT email DOT address DOT com (Flatulator) Newsgroups: comp.os.msdos.djgpp,comp.lang.objective-c Subject: please help me to compile an Objective-C program Date: Thu, 13 Aug 1998 03:26:54 GMT Organization: NeoSoft, Inc. Lines: 97 Message-ID: <35d25c2c.9025265@news.neosoft.com> NNTP-Posting-Host: as5200-port-96.no.neosoft.com To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Hi. I'm new to Objective-C and I'm trying to compile this sample program. I'm using DJGPP v2 to do it. I did everything perfectly as far as I can tell and I got some "undefined reference" error messages. The files in question are main.m, Printer.m, and Printer.h. Here's what I'm typing to compile: gcc -c main.m (no problem) gcc -c Printer.m (no problem) gcc -lobjc main.o Printer.o (Problem occurs here) Here are the error messages: main.o(.text+0x31):main.m: undefined reference to `objc_get_class' main.o(.text+0x3c):main.m: undefined reference to `objc_msg_lookup' main.o(.text+0x54):main.m: undefined reference to `objc_msg_lookup' main.o(.text+0x77):main.m: undefined reference to `objc_msg_lookup' main.o(.text+0x9f):main.m: undefined reference to `objc_msg_lookup' main.o(.text+0xc4):main.m: undefined reference to `objc_msg_lookup' main.o(.text+0xed):main.m: undefined reference to `__objc_exec_class' Printer.o(.text+0x20):Printer.m: undefined reference to `objc_msg_lookup_super' Printer.o(.text+0x41):Printer.m: undefined reference to `objc_msg_lookup' Printer.o(.text+0xb1):Printer.m: undefined reference to `objc_msg_lookup' Printer.o(.text+0x105):Printer.m: undefined reference to `__objc_exec_class' Printer.o(.text+0x110):Printer.m: undefined reference to `__objc_class_name_Obje ct' I would be ever so grateful if some kind soul could help me compile this program. I feel certain it's a link time error. The contents of the files in this program follow. Also, I tried compiling this in gcc in some UNIX and I got the exact same problem. --------Here is main.m------------ #import "Printer.h" void main() { id printer = [[Printer alloc] init]; [printer addStringValue:"Hello World!"]; [printer print]; [printer free]; } --------Here's Printer.m-------------- #import "Printer.h" @implementation Printer -init { [super init]; [self clear]; return self; } - addStringValue:(const char*) astring { strcat(buffer, astring); return self; } - print { printf("%s\n",buffer); [self clear]; return self; } - clear { strcpy(buffer, ""); return self; } @end -------------Here's Printer.h--------------- #import @interface Printer: Object { char buffer[100]; } - init; - addStringValue: (const char *)astring; - print; - clear; @end