A Developer's Diary

Jun 17, 2012

Getting started with Objective C on Ubuntu with GNUStep

Setting up the Environment

1. Install the following packages using the apt-get command.

sudo apt-get install build-essential
sudo apt-get install gnustep
sudo apt-get install gnustep-make
sudo apt-get install gobjc
sudo apt-get install libgnustep-base-dev
sudo apt-get install libgnustep-gui-dev

The GNUstep makefiles are placed under the following directory /usr/share/GNUstep/Makefiles

2. Export variable GNUSTEP_MAKEFILES which points to the GNUStep makefiles location.
export GNUSTEP_MAKEFILES=/usr/share/GNUstep/Makefiles/

You can otherwise define this variable in the GNUstep makefile exclusively as
GNUSTEP_MAKEFILES=/usr/share/GNUstep/Makefiles

Running the Hello World application
The HelloWorld Program
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>

int main()
{
  NSAutoreleasePool *pool = [NSAutoreleasePool new];

  [NSApplication sharedApplication];
  NSRunAlertPanel (@"Hello World", @"Hello from the GNUstep AppKit", nil, nil, nil);

  return 0;
}

The GNUmakefile for building the HelloWorld Application
#################################################
#          File: GNUmakefile
#################################################

include $(GNUSTEP_MAKEFILES)/common.make
APP_NAME = HelloWorldApp
HelloWorldApp_OBJC_FILES = HelloWorld.m
include $(GNUSTEP_MAKEFILES)/application.make

Compiling and Building the Application
make

Running the Application

openapp ./HelloWorldApp.app



Refernces:
GNUstep Tutorial

No comments :

Post a Comment