Build an object-C environment under codeblocks

Source: Internet
Author: User

Objective-C is the programming language of Apple software. It is much easier to have an integrated development environment (IDE) for machine learning and debugging. There are three ways to build an integrated development environment for objective-C:

1) Use the apple platform and integrate the development environment with xcode. However, if you do not have an apple platform and want to learn objective-C in a Windows environment, you can use either of the following methods:

2) set up an apple virtual machine in a Windows environment, but this requires a high performance for personal computers. Not all personal computers can, and the virtual machine runs slowly;

3) use the codeblocks IDE development environment to configure it and build an integrated development environment that supports object-C compilation, debugging, and running. This method has almost no requirements on the Performance of personal computers and can be quickly built. This method is described in this article.

1. Install the object-C Compiler

There are many objective-C compilers. This article describes how to use gnustep at http://www.gnustep.org/experience/windows.html. Here we can download the gcccompiler for Windows:

Go to the download page, download the above four software packages, and install them, for example, to c: \ gnustep. The functions of these three software packages can be queried online.

2. Install the integrated development environment of Object-C

We chose codeblocks ide as the integrated development environment for objective-C, which is http://www.codeblocks.org /.

3. Development Environment Configuration

Configure code blocks to build the objective-C development environment step by step.

Step 1: configure the Compiler

Go to settings-> compiler and debugger..., select the GNU gcc compiler, press the "copy" button, rename it "gnustep mingw compiler", and save it.

Then go to the other options page and enter:

-Fconstant-string-class = nsconstantstring-STD = c99

Step 2: Set linker stettings for the connector

Add two files to the link libraries ,.

They are under D: \ gnustep \ System \ library \ libraries:

Libgnustep-base.dll.a

Libobjc. dll.

Step 3: Specify the search directory search directories (you need to install gnustep in advance)

1) compiler (compiler) is set to D: \ gnustep \ System \ library \ headers;

2) linker (connector) is set to D: \ gnustep \ System \ library \ libraries;

3). toolchainSet it to c: \ gnustep (set it to the gnustep path)

This step is not involved in many blogs on the Internet. If it is not set, the error: no such fileor... may occur during run ...)

Step 4: add support for objective-C file types

1) choose Settings> environment... and select files extension handling to add *. M.

2) choose Project> Project tree> edit file types & categories... and add *. m to the file type list under sources.

3) Go to settings-> editor..., select syntax highlighting, click "filemasks...", and add *. m to the file type at the end of the pop-up box.

4) Click the "keywords..." button (close to the filemasks... button) to add the following object-C keywords to the edit keywords list ..

@ Interface @ implementation @ end @ Class @ selector @ Protocol @ public @ protected @ Private ID bool yes no Sel nil null self

4. Code Testing

After the preceding development environment is configured, you can start code testing.

First, create a new project, select File-> New-> project ..., A project type window appears. Select console application and follow the Project Creation instructions to create a mytest project, rename the main. c file to main. m, and enter the following code:

# Import <Foundation/Foundation. h>

Int main (INT argc, const char * argv [])

{

NSAID utoreleasepool * Pool = [[NSAID utoreleasepool alloc] init];

Nslog (@ "% @", @ "Hello World ");

[Pool drain];

Return 0;

}

Note the compiler:

Rename: Right-click and select renamefiles before you double-click main. cpp.


Then compile and run: buid-> run... If the following window appears, congratulations, you have successfully set up the integrated development environment for objective-C in windows.

Blog collation Source:

Http://blog.sina.com.cn/s/blog_a67a99d70101hl5n.html

Http://wenku.baidu.com/view/9ffed817f18583d0496459ca.html

Extension:

Iteye: codeblocks configuration development use cocoa framework to develop GUI programs.

Http://kingj.iteye.com/blog/1562989

Wikipedia:

Http://wiki.codeblocks.org/index.php? The title = Installing_Objective-C_Compiler # setup_the_compiler


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.