1. Install the Compiler
There are many Objective-C compilers. LLVM is developed from GCC and is mainly used on Apple's platform. GNU can use GnuStep, which is a program called Objective c.
Go to the download page and download the above three software packages for installation, for example, to D: \ GNUstep,
2. Install the CodeBlocks IDE environment
: Http: // www.Codeblocks. Org/
3. Configure the Compiler
After codeblocks is installed, goSettings-> Compiler and debugger..., SelectGnu gcc Compiler, copy againName it "GNUstep MinGW Compiler"
Compile other options:-Fconstant-string-class = NSConstantString-std = c99
Specify the search directory at the same time:
The compiler's search directory is D: \ GNUstep \ System \ Library \ Headers.
Set the linker search directory to D: \ GNUstep \ System \ Library \ Libraries, and set the linker parameter:-lobjc-lgnustep-base
Alternatively, you can add two file libgnustep-base.dll.a, libobjc. dll. a, under D: \ GNUstep \ System \ Library \ Libraries, to the linker Option
Set the search directory for compilers and connectors
4. Configuration syntax, file type, and keywords
Support for adding file types
1) EnterSettings-> Environment...
2) SelectFiles extension handlingAdd*. M
3) EnterProject-> Project tree-> Edit file types & categories...
4) InSources, Add*. MTo the file type list.
Add syntax highlighting support
1) EnterSettings-> Editor...
2) SelectSyntax highlightingEnterFilemasks.... Add*. MTo the file type list.
3) EnterKeywords...(CloseFilemasks...) Add the following keywords to the list.
@ Interface @ implementation @ end @ class @ selector @ protocol @ public @ protected @ private id bool yes no sel nil NULL self |
Add *. m extension to syntax highlighting
5. Code Testing
Create a new project, change main. c to main. m, and enter the following code:
#import <Foundation/Foundation.h>int main (int argc, const char *argv[]){ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSLog(@"%@",@"hello world"); [pool drain]; return 0;}
The compilation and running effect is as follows:
17:33:49. 711 objc1 [6080] hello world
Process returned 0 (0x0) execution time: 0.220 s
Press any key to continue.
Source: http://blog.csdn.net/wxw45601/article/details/7484056