I struggled with this for a while myself, but I think I've got it working.
To compile PURE Objective-C -- that is, NO GNUSTEP -- you can just do a command like this from the command line (where foo.m is your source code):
$ gcc -lobjc foo.m -o foo_run
Basically, the same as for compiling any other code with gcc, except you include "-lobjc" to link the Objective-C library.
But, there isn't much point in writing Objective-C without GNUStep. To use GNUStep, I had to do the following:
1. Make sure the gnustep-common package is installed. (Of course, you also need build-essentials and gobjc, and perhaps others...)
2. You have to use a makefile. In the directory with your file, save this as "GNUmakefile:"
include ${GNUSTEP_MAKEFILES}/common.make
TOOL_NAME = MyApp
LogTest_OBJC_FILES = code.m
include ${GNUSTEP_MAKEFILES}/tool.make
3. Now, you need code to compile. Try this from the GNUStep tutorial:
#import <Foundation/Foundation.h>
int main (void)
{
NSLog (@"Executing");
return 0;
}
4. Next step--and this is a bear--is to run a shell script that assigns values to variables like GNUSTEP_MAKEFILES. Why the package doesn't do this for you, I don't know.
$ cd /usr/share/GNUstep/Makefiles/
$ sudo chmod +x GNUstep.sh
$ . ./GNUstep.sh
5. Now, cd back to your directory with the makefile and the source, and type "make." It should compile and put the executable in a new directory named "obj."
Bookmarks