Tag Archives: compiling

Steven Compiling Objective C in Ubuntu by

After several hours of searching through other guides, objective-c now compiles on Ubuntu 11.04.
Retracing my steps, I believe THIS is how I did it:

1. Install GNUstep

GNUstep is the open-source version of Cocoa, and contains many of the same development tools and APIs.
Source is available

Or just type the following in terminal:
sudo apt-get install gobjc gnustep gnustep-make gnustep-common

2. Setup GNUstep environment
Execute the following script in order to set up the GNUstep environment for the current terminal session
. /usr/share/GNUstep/Makefiles/GNUstep.sh

Additionally, you can add the this to the bottom of your ~/.bashrc file so you don’t have to run it manually.

3. Compile with gnustep flags

Assuming you already have the gcc compiler, add these flags for objective c files.
gcc 'gnustep-config --objc-flags' -lgnustep-base -o

So for example, the files helloworld.m,helloworld.h would be compiled like so:
gcc 'gnustep-config --objc-flags' -lgnustep-base helloworld.m -o helloworld

This should compile silently, and can then be executed with:

Haven’t tested this with any Objc 2.0 features, but its enough to start doing some basic tutorials.