Google Ads

April 22, 2015

Setup Objective-C programming environment on Ubuntu Distributions

Objective-C is a programming language which expands C programming language by including Smalltalk object orientated programming language. It has robustness like C programming language as well as it is feature rich like C++ and Java. It fully supports object oriented programming including Encapsulation, Data hiding, Inheritance and Polymorphism. It is the main programming language for OS X and iOS application development.

GNU Compiler Collection (GCC) provides compiling support for Objective-C source files through GNUstep framework. It is very easy to setup Objective-C development environment on Ubuntu based distributions. We just have to install few packages on to our Ubuntu System.


From your favourite package manager just install the following packages:


gobjc

gnustep
gnustep-make
gnustep-common
gnustep-core-devel
gnustep-devel

Or in the terminal put the following command:


sudo apt-get install gobjc gnustep gnustep-make gnustep-common gnustep-core-devel gnustep-devel


Once all the packages are installed properly, you should be able to compile any Objective-C source file by entering the following command in the terminal:


gcc source.m `gnustep-config --objc-flags` -lobjc -lgnustep-base


This should produce a.out binary in the current directory.


For Example, put the following codes into a text editor and save it as Hello.m


#import <Foundation/Foundation.h>

int main(int argc, char *argv[])

{
    NSLog(@"Hello, World!\n");
   
   return 0;
}

Now, compile the source file Hello.m using following command in the terminal:


gcc Hello.m `gnustep-config --objc-flags` -lobjc -lgnustep-base


Now, run the executable file by putting following command in the terminal:


./a.out


You should see something like below in the terminal,


2015-04-22 19:24:26.483 a.out[31686] Hello, World!


1 comment: