ObjectiveC on Ubuntu Linux
Hi,
as I’m about to become an iPhone programmer (another one?), I’ve decided to set up an objective-c environment on my Ubuntu too.
First, I’ve downloaded all the packages for ObjectiveC and GNUstep I’ve found on Synaptic.
Second, I’ve tried to compile a classical Hello World file with gcc. Here’s the code (’Ciao mondo’ stands for ‘Hello world’ in Italian):
#import <Foundation/Foundation.h>
int main(int argc, char* argv[]) {
NSLog(@"Ciao mondo");
return 0;
}
and i saved the source in a file called main.m
After that I’ve tried: gcc main.c -o hello and I soon got the following error message:
main.m:2:34: error: Foundation/Foundation.h: No such file or directory main.m: In function ‘main’: main.m:5: error: cannot find interface declaration for ‘NXConstantString’
So after surfing a while on Yahoo’s search results, I came to the solution:
1. Execute
. /usr/share/GNUstep/Makefiles/GNUstep.sh
to initialize the environment variables for the GNUstep.
2. Use the gnustep-config –objc-flags to retrieve the correct flags for gcc and link the main.m with the gnustep-base library, this way:
gcc `gnustep-config --objc-flags` -lgnustep-base main.m -o hello
3. Execute ./hello and you’ll got:
2008-08-07 14:58:13.537 hello[20074] Ciao mondo
- See also:
- Writing GNUstep makefiles and
- Additional Installation on GNUstep.org
Enjoy,
Rob.
Tags: GNUstep, ObjectiveC




January 30th, 2009 at 1:53 am
[…] ter lido alguns how-to’s aqui e ali, resolvi testar. Segui os seguintes […]