Build an Object-C development environment in Ubuntu

Source: Internet
Author: User
I. From one o'clock P.M. to half past five, four simple applications were introduced at the iPhone application presentation, which is really interesting. 2. There are three methods below, only the third method successfully 1. YoucanprogramtheObjective-CwithoutMacBook.PleasereferthebelowlinktoinstallObjective-Ccompilerinyo

I. From one o'clock P.M. to half past five, four simple applications were introduced at the iPhone application presentation, which is really interesting.

2. There are three methods below, and only the third method is successful.

1. You can program the Objective-C without MacBook.
Please refer the below link to install Objective-C compiler in you Ubuntu
Mchine.
Http://d.hatena.ne.jp/tomute/20090112/1231809116

2. Set up the Object-C Development Environment (for conversion) in Ubuntu 9.10 (This write is complete but fails)
Object-C is an extension of the C language by Apple, but its supporting development environment must run on the Leopard system, and the system must run on the Mac machine, but I am still a student, changing the system to Leopard is not quite feasible. It is really willing to change the current system to Leopard. It didn't take much effort to configure this system at the beginning, and the performance of installing Leopard on virtual machines is unacceptable, unfortunately, we can only try to build a development environment other than Xcode. Fortunately, we can use GNUStep In Ubuntu. There are a lot of instructions on the installation process on the Internet, but they are not detailed, there are still a lot of errors, and even more helpless is that there are still N people who don't verify that the content is correct or incorrect, so they can post it and bring a lot of trouble to the search, I had no choice but to study it and check the information again. Now I have to explain the specific steps:

1) install gnustep-devel. You can use sudo apt-get install gnustep-devel to install it, but it will tell you that many packages are no longer available, A better solution is to use the new software package manager to install the package. After opening the package, enter gnustep-devel and right-click it to mark the installation. You will be prompted to install many other dependent packages. Confirm the installation first, click the application.

2) After installation, it is also the most critical step. It is to configure the environment variables of gnustep-make. Unlike windows, Ubuntu user environment variables are placed. in the bashrc file, this file is in the root directory of the user. Of course, you cannot find it because it is hidden. If the Ubuntu system wants to hide the file, it is added before the file name ., the method for displaying hidden files is Ctrl + H. Therefore, you can find the hidden files in the root directory. cshrc, add the following configuration at the end:

# Set GNUstep
GNUSTEP_ROOT =/usr/share/GNUstep
Export GNUSTEP_ROOT
Source/usr/share/GNUstep/Makefiles/GNUstep. sh

If you do not add the above configuration, the/common will be prompted when compiling the objective-c source file. make,/tool. make cannot be found, which has plagued me for a long time, so this is very important.

After completing the above configuration, we have already set up the object-c development environment. Next we will use gnustep to develop an object-c for testing.

1) application-> programming-> Project Manager IDE-> File-> New-> Source File-> Objective-C Language Source File

Then write a simple Hello World Program

2) File-> Save is saved in a directory. Remember to Save it as the Objective-C type. You can see that the File type is. m.

3) then create an empty file in the directory. No file type is required, but the name must be GNUmakefile. The content is as follows:

Include $ (GNUSTEP_MAKEFILES)/common. make

TOOL_NAME = LogTest
LogTest_OBJC_FILES = source. m

Include $ (GNUSTEP_MAKEFILES)/tool. make

Here, LogTest can be changed to the task name, which indicates the executable file name after compilation. It only needs to be unified in two places, source. m is the original file name you just saved and replaced it with your own. Here $ (GNUSTEP_MAKEFILES) references the path of the gnustep-make we set, so there is no step 2nd setting, the corresponding directory cannot be found.

4) after writing the file, enter the directory on the terminal and execute make. If everything is okay, an obj directory will be added to the directory, it contains compiled executable files.

5) Run./obj/LogTest again to see the running result. Note that the LogTest here corresponds to the above. Of course, you can replace it with your own


3. Build the development environment of Object-c in Ubuntu (this is simple and successful)

The Gnu Compiler only supports the most basic part of Object-c. To use the entire Objective-C Cocoa/openStep environment in Ubuntu, therefore, you must install the packages supported by gcc, gcc, and Objective-C, and the GNUstep environment.

First install gnustep and gobjc

Sudo apt-get install gobjc gnustep-devel

Get a Hello world code and try to compile it once.

# Import

Int main (int argc, const char * argv []) {
Printf ("hello world \ n ");
Return 0;
}

Then execute the compilation:

Gcc hello. m-o hello

If the object-c library is called, the above compilation command will fail. Use the following command:

Gcc 'gnustep-config -- objc-flags '-lgnustep-base hello. m-o hello

Then let the Code look at it

./Hello

Entered

Hello world

OK

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.