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

Enjoy,
Rob.

Tags: ,

One Response to “ObjectiveC on Ubuntu Linux”

  1. Carlan+Calazans » Blog Archive » Dica: Objective-C no Ubuntu Says:

    […] ter lido alguns how-to’s aqui e ali, resolvi testar. Segui os seguintes […]


 
Roberto Rocco Angeloni is proudly powered by WordPress
Entries (RSS) and Comments (RSS).

Fatal error: Cannot access protected property ObjectMgr::$_verbose in /web/htdocs/www.roccoangeloni.it/home/wp/wp-content/themes/rra/include.php on line 22