Re: NSObject errors compiling Objective-C programs
Sašo Kiselkov <[email protected]>
| Newsgroups | gmane.comp.lib.gnustep.user |
|---|---|
| Message-ID | <[email protected]> |
The problem is in your GNUmakefile. Replace OBJC_PROGRAM_NAME with TOOL_NAME and instead of include $(GNUSTEP_MAKEFILES)/objc.make do include $(GNUSTEP_MAKEFILES)/tool.make Your problem is based on the fact that GNUstep-make allows you to also build "plain" Objective-C programs with no dependency on GNUstep-base or GNUstep-gui whatsoever - that's what "OBJC_PROGRAM_NAME" and "objc.make" are for. However, NSObject is defined in GNUstep-base, so you need to use "TOOL_NAME" and "tool.make" = a command line program with gnustep-base (but without gnustep-gui) linked in. Quoting "Mehul N. Sanghvi" <[email protected]>: > > OK, so I've got gnustep-base and gnustep-make installed. I'm trying to > follow the code as given on the "Objective-C for Beginners" website > which is refrenced from the gnustep.org website. > > I am getting the following error when I try to compile the simple > fractions example: > > prompt% make > Making all for objc_program fraction_driver... > Compiling file fraction_driver.m ... > Compiling file fraction.m ... > Linking objc_program fraction_driver ... > ./shared_obj/fraction.o(.data.rel+0xf4): undefined reference to > `__objc_class_name_NSObject' > collect2: ld returned 1 exit status > make[1]: *** [shared_obj/fraction_driver] Error 1 > make: *** [fraction_driver.all.objc-program.variables] Error 2 > > > What am I doing wrong ? I'm just trying to compile a simple > Objective-C program, using the GNUstep make system. > > > cheers, > > mehul > > > ---- begin header file ---- > #import <Foundation/Foundation.h> > > @interface Fraction: NSObject > { > int numerator; > int denominator; > } > > /* rest of code snipped */ > ---- end header file ---- > > > ==== GNUmakefile ==== > include $(GNUSTEP_MAKEFILES)/common.make > > # Space seperated list of executables to be built > > OBJC_PROGRAM_NAME = fraction_driver > > fraction_driver_OBJC_FILES = fraction_driver.m fraction.m > > include GNUmakefile.preamble > include $(GNUSTEP_MAKEFILES)/objc.make > ==== GNUmakefile ends ==== > > > ~~~~ GNUmakefile.preamble ~~~~~ > ADDITIONAL_OBJCFLAGS += -Wall -Wno-import #-fnext-runtime > > ~~~~ GNUmakefile.preamble ~~~~~ > > > > > -- > Mehul N. Sanghvi > email: [email protected] -- Saso