Using Codeblock to build a objec-c learning environment under windows

Source: Internet
Author: User

Learning Object-c If you are using Windows, it is generally recommended to use a virtual machine, but it is too heavyweight to download the os-x first and download the X-code. A relatively simple way to use Code-block to build a simple object-c learning environment is recommended here: http://www.codblocks.org/.

Objective-c compiler has many, here use GNUstep, URL is http://www.gnustep.org/experience/ Windows.html, from here you can download the Windows version of the GCC compiler, a total of four packages, of which GNUstep system and GNUstep core are required, GNUstep Devel and Cairo Backend is optional (use Thunder to drag quickly).

After downloading and installing the Code-block and GnuStep, configure the Code-block.

Open code::blocks, click menu Settings>compiler and Debugger>global Compiler settings Click Copy under the selected Compiler drop-down box After filling in the pop-up window: GNUstep MinGW compiler, click the Toolchain Executables tab and select compiler's installation directory as C:\GNUstep, such as:

Next find the other Options tab , write :-fconstant-string-class=nsconstantstring-std=c99:

Next set up the static link library, add in link settings, need to add. A file in: C:\GNUSTEP\GNUSTEP\SYSTEM\LIBRARY\LIBRARIES:LIBGNUSTEP-BASE.DLL.A and LIBOBJC.DLL.A,

    

Next add in the Compiler tab in search Irectories: C:\GNUstep\GNUstep\System\Library\Headers; In the Linker tab, add: C:\GNUstep\ Gnustep\system\library\libraries. It's not here.

Enter settings->environment ..., select files extension handling add *.m; Enter Project->projecttree->edit File Types & Categories ... , in sources, add *.m to the file type list below.

Enter Settings->editor ..., select syntaxhighlighting, click the "Filemasks ..." button, add *.m to the file type at the end of the popup box, and click the "Keywords ..." button ( Close to Filemasks ... button) Add the following object-c keyword to the editkeywords list: @interface @implementation @end @class @selector @protocol the @public @ Private ID BOOL YES NO SEL nil NULL self.

     

Final Test, select file->new->project ..., a project type window will appear, select Console application, then follow the construction guidelines to establish a mtest project, and rename the Main.c file to main.m, write the code:

#import <foundation/foundation.h>int Main (int argc, const char * argv[]) {    NSAutoreleasePool * pool = [Nsautore Leasepool alloc] init];    NSDate *now = [NSDate date];    NSLog (@ "This NSDate object lives at%p", now);    NSLog (@ "The date is%@", now);    [Pool drain];    return 0;}

Compile and run the above code with the following results:

  

Using Codeblock to build a objec-c learning environment under windows

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.