How to compile objective-C on Windows

Source: Internet
Author: User
Tags keywords list

When you do not have a Mac or virtual machine, compile objective-C in windows.ProgramWhat about ??

Next, I will explain in detail how to compile objective-C language in windows.

1. Install the object-C Compiler
There are many objective-C compilers. This article introduces the use of gnustep.
Http://www.gnustep.org/experience/windows.html, you can download
GCC compiler:

Download these three files, for example, to the: D: \ OC Compiler

2. Install the integrated development environment of Object-C

Codeblocks-12.11mingw-setup.exe

3. Development Environment Configuration
Configure code blocks to build the objective-C development environment step by step. Codeblocks, yes
You can see the following picture:

Step 1: configure the Compiler
Go to settings-> compiler and debugger..., select the GNU gcc compiler, and press "copy"
Button, rename it as "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: \ OC compiler \ gnustep \ System \ library \ headers;




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

Step 4: add support for objective-C file types
1) choose Settings> environment... and select files extension handling to add *. M.

2) Go to project> Project tree> edit file types & categories..., and add
Add *. m to the file type list.

3) choose Settings> editor..., select syntax highlighting, and click "filemasks,
Add *. m to the file type at the end of the dialog box.

4) Click the "keywords..." button (close to the filemasks... button) to add the following object-C keyword
In the edit keywords list ..
@ Interface @ implementation @ end @ Class @ selector @ Protocol @ public @ protected
@ Private ID bool yes no Sel nil null self




4.CodeTest
After the preceding development environment is configured, you can start code testing.
First, create a new project, select File> New> pr oject ..., A project type window appears. Select
Console application, and then follow the Project Creation instructions to create a mytest project, and
And enter the following code:

 
# Import <Foundation/Foundation. h> int main (INT argc, const char * argv []) {ngutoreleasepool * Pool = [[ngutoreleasepool alloc] init]; nslog (@ "% @", @ "Hello World"); [pool drain]; return 0 ;}

So far, all installation is complete.

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.