How to install and use objective-c under Ubuntu

Source: Internet
Author: User

Objective-c is the best Class C, object-oriented programming language I have used. Objective-c is perfectly compatible with standard C, and on top of this is the Smalltalk element that interprets the fundamental concept of object-oriented, making it both concise and flexible, and is definitely the first programming language tool for commercialization projects. It is closer to the bottom than Java, you can directly write inline assembly or directly with the assembly file (because it is the C language, on the basis of the C language to expand the Smalltalk message mechanism and OO mechanism). Compared with C + +, it is clearly a lot more concise, C + + God horse inheritance, virtual inheritance, the pit of the majority of endless. Objective-c is very easy to get started, and the syntax is not complex, so it will not cause the programmer to appear too bad, the whole project is very easy to maintain.

So, whether under Unix/linux or OS X/ios, programming with OBJECTIVE-C is a pleasure. Below I will show you how to install and compile objective-c under the latest version of Ubuntu (14.10).


Since Ubuntu already has a objective-c compiler (GOBJC) installed, the steps to install GOBJC can be saved if you use the Ubuntu side system is not installed can use the following command to install--

sudo Install GOBJC

Next, we are mainly the installation of the GNUstep library. To OS X or iOS programming friends should be familiar with the foundation library, this is in the GNUstep library, if not installed this library, you even nsobject can not use, Whistling ~ First installed GNUstep

sudo Install GNUstep

When we're done, we'll install Gnustep-devel.

sudo Install Gnustep-devel


This will install the entire installation environment. We can write a piece of code to compile it below.

Before compiling, we entered the/usr/share/gnustep/makefiles directory to set up the compilation environment and execute it in the current console (terminal):

sudo bash/usr/share/gnustep/makefiles/gnustep. SH


In this way, the GNUstep compilation environment for the current console is established. Then we're going to work on a project that can create a folder. Then create a main.m file in the first:

#import <Foundation/Foundation.h>int main (void) {    *pool = [[ NSAutoreleasePool alloc] init];        NSLog (@ "Hello, world! " );     = u' plus ';    NSLog (@ "Thecharacter is:%c", C);    [Pool drain];}

After that, we create a make file named: Gnumakefile

Gnustep_makefiles =/usr/share/gnustep/makefilesinclude $ (gnustep_makefiles)/common.  Make  + =-std== = Main.minclude $ (gnustep_makefiles)/tool.  Make

Since we used the C11 standard in the source code to introduce the Unicode prefix literal expression--u ' plus ', which represents a UTF-16 character, we also added-std= in Gnumakefile Gnu11 This compilation option to allow the compiler to use the latest C11 standard with the GNU canonical syntax extension.

It is important to note that for other Linux versions of the system, the default installation path for GNUstep may not be in/usr/share/, so the gnustep_makefiles needs to be set according to the current gnustep/makefiles path. And this variable must be defined before the include.

The following tool_name specifies the final target executable file name after make. This is named Test.


After that, if we have done gnustep.sh before, then you can just knock make and enter. The project is built to completion. If you have errors such as "gcc:error trying to exec ' cc1obj ': execvp:no such file or directory", then you will also need to install GOBJC.


Additional reference links are provided below:

Http://www.techotopia.com/index.php/Installing_and_Using_GNUstep_and_Objective-C_on_Linux

Http://www.gnustep.org/resources/documentation/Developer/Base/ProgrammingManual/manual_1.html#SEC11


Note here that for the first link, if you knock GCC directly at the command line, it cannot be successfully connected because the GNUstep library cannot be found. So the best way is to solve the problem by using makefile.

How to install and use objective-c under Ubuntu

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.