Objective-C development-CodeBlocks instance operations

Source: Internet
Author: User
Tags cairo

Objective-CDevelopmentCodeBlocksThe content of instance operations is described in this article.CodeBlocksFor more information, see the details.

1. First install the Objective-C Compiler

GNUstep Windows Installer provides a simulated development environment for Objective-C on the Windows platform. There are four software packages, including GNUstep System and GNUstep Core, GNUstep Devel and Cairo Backend are optional. Render manager must be installed and installed at one time, so as to avoid future troubles.

Install all four files in C: GNUstep.

 
 
  1. http://ftpmain.gnustep.org/pub/gnustep/binaries/windows/gnustep-msys-system-0.25.1-setup.exe  
  2.  
  3. http://ftpmain.gnustep.org/pub/gnustep/binaries/windows/gnustep-core-0.25.0-setup.exe  
  4.  
  5. http://ftpmain.gnustep.org/pub/gnustep/binaries/windows/gnustep-devel-1.1.1-setup.exe  
  6.  
  7. http://ftpmain.gnustep.org/pub/gnustep/binaries/windows/gnustep-cairo-0.22.1-setup.exe 

2. Add a compiler for Code: Blocks

Open Code: Blocks, and choose Settings> Compiler and debugger> Global compiler settings.

Click Copy in the Selected compiler drop-down box and enter GNUstep MinGW Compiler in the pop-up window.

Click the executables Tab Of The Toolchain and select "C: GNUstepmingwbin" as the "Compiler's installation directory ".

3. Create an Objective-C Project

Create a Console C Project, Delete main. c, and create a new main. m file. The content is as follows:

 
 
  1. #import <Foundation/Foundation.h> 
  2. int main (int argc, const char *argv[]) {  
  3.     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];  
  4.     NSLog(@"Hello World!");  
  5.     [pool drain];  
  6.     return 0;  

Right-click main. m and click the property tab, select the Build tab, tick both Compile file and Link file, select Advanced, and change the content of Compiler variable to CC.

4. Set compilation options

(1) method 1

Right-click the project to be created, and select Build options ..., Selected compiler Compiler select GNUstep MinGW Compiler, select compiler settings> Other options and fill in-fconstant-string-class = NSConstantString

Select the Linker settings tab and click Add to Add the following two lines:

 
 
  1. C:/GNUstep/GNUstep/System/Library/Libraries/libobjc.dll.a  
  2. C:/GNUstep/GNUstep/System/Library/Libraries/libgnustep-base.dll.a 

Select Search directories> Compiler and click Add to Add the following content:

 
 
  1. C:/GNUstep/GNUstep/System/Library/Headers 

(2) method 2

Right-click the project to be created, and select Build options ..., Select GNUstep MinGW compiler as the Selected Compiler, and select compiler settings> Other options.

 
 
  1. -fconstant-string-class=NSConstantString -IC:/GNUstep/GNUstep/System/Library/Headers  
  2.    -LC:/GNUstep/GNUstep/System/Library/Libraries 

Select the Linker settings tab and enter-lobjc-lgnustep-base in Other linker options.

5. Add. m file type highlighting and editor Association

(1) click Settings> Editors> Syntax highlighting, select Syntax highlighting for: C/C ++, and click Filemasks ..., Add *. m to the pop-up window and click OK.
Select Matlab, click Filemasks ..., Delete *. m

(2) click Settings> Environment> Files extension handling, click *. m, and select

Open it in a Code: Blocks editor.

Summary:Objective-CDevelopmentCodeBlocksI hope this article will help you with the introduction of instance operations!

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.