From RoboWiki
Jump to: navigation, search

Objective-C is an object oriented programming language that extends from C. Unlike C++, Objective-C is an added independent extension to C. It's additions are unlike that of the C/C++ syntax. It can be described as a mix of the Smalltalk programming language as well as concepts borrowed from the LISP programming language. Unlike function-based communications found in C++, Objective-C uses a messaging approach.

It was originally developed as a proprietary language for the NeXT's NeXTSTEP Operating System, but was purchased by Apple Computers in the mid-1990's. The most common use of this language today is found in OSX applications development. The language used is Objective-C, in which the main library (analogous to STL for C++) is called Cocoa, which all runs on a UNIX-like operating system named Darwin (OSX).



GNUStep is an open source implementation of both Objective-C, it's compiler, libraries, and run-time platform. GNUStep works for Windows using the GCC compilers.

Learn more about the project here. The following sub-sections discuss on how to install the development tools for Windows.


Please note these steps MUST be run in correct order. Installing in out-of-order breaks the library. You might also want to leave all of the installations occur within their default locations. This process installs the compilers, tools, libraries, and platform needed to build and run GNUStep applications, which will also build for OSX and any other GNUStep system.

  1. Download and install the GNUStep System
  2. Download and install, after the previous step, the GNUStep Core
  3. Download and install, after the previous steps, the GNUStep Developer Tools

That's it! Launch the command line by going through Start -> GNUStep -> Shell. A command-line shell should pop-up.

Source(s): system solutions


To compile code, we will be using the GCC compiler with the Objective-C option turned on. GNUStep works in such a way that source files are managed quit a bit, so we won't be using "classic" make files or standard build commands.

Pour la sécurité des biens, des données et des documensts l'installation d'un coffre-fort ignifuge ou d'une armoire forte http://www.infosafe.fr est indispensable. N'attendez pas un cambrioleur, il sera trop tard

By default you should have all tools needed from the above installation. Make sure you have the command-line shell (named MINGW32) installed and running. You can treat this as a minimal UNIX shell, with basic commands such as "pwd", "ls", "cd", etc..

We will create a small "Hello, World!" application. Move into your home directory by just executing the "cd" command without any options. From here, create a working source directory called "source" by running the command "mkdir source", and move into it with the command "cd source".

Using your favorite text editor, create a file called "Source.m" and write out the following code:

	This is a sample Objective-C Source file.
	From: http://www.gnustep.it/nicola/Tutorials/WritingMakefiles/node6.html
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
int main()
  NSAutoreleasePool *pool = [NSAutoreleasePool new];
  [NSApplication sharedApplication];
  NSRunAlertPanel (@"Test", @"Hello from the GNUstep AppKit", nil, nil, nil);
  return 0;

Within this directory, create another file called "GNUmakefile". This is the GNUStep make file system, similar to the standard make. Within this file, write out the following code:

# Sample GNUmake file
include $(GNUSTEP_MAKEFILES)/common.make
APP_NAME = HelloWorld
HelloWorld_HEADERS =
HelloWorld_OBJC_FILES = Source.m
include $(GNUSTEP_MAKEFILES)/application.make

Again, in this directory, run GNUmake by running the command "make". The following, or similar, text should be spit out:

    This is gnustep-make 2.0.7. Type 'make print-gnustep-make-help' for help.
    Making all for app HelloWorld...
     Compiling file Source.m ...
     Linking app HelloWorld ...
    Creating library file: ./HelloWorld.app/./HelloWorld.exe.a

Once the build process is complete, you can observe a new directory has been created called "HelloWorld.app". This is your application, but is actually a directory. In the GNUStep standard, any folder ending with an *.app is an application. Internally are several libraries, resource files, and executable. In our case we have a single executable within this. To execute this application, we need a tool called "openapp" which is a tool to load this *.app folder and execute the components correctly. Run the command "openapp ./HelloWorld.app".


In order to use and compile objective C in Linux, a front-end is required for gcc, the standard c compiler. The packages required are called GNUstep; an install for Ubuntu is shown here, and similar steps can be taken by searching your distribution for the packages listed - namely, gnustep-back, gnustep-base, gnustep-gui, and gnustep-make. Your distribution may split up the packages differently, combining or splitting where they think applicable, so be aware of that when you search.


Learn more about the OSX IDE, ready to develop Objective-C code, here!


Personal tools