[Objective-C] building an objective-C development environment in win

Source: Internet
Author: User

Gnustep

First, there is no objective-c ide in windows. objectiveeclipse is an optional plug-in that works with eclipse3.5 + cdt6.0, but the update has stopped. Gnustep is an API and tool similar to cocoa (Apple OS Development Framework). It currently supports GNU/Linux and GNU/Hurd, Solaris, NetBSD, OpenBSD, FreeBSD, Darwin, and windows, free to use. This project enables Objective C to be developed and run on most popular platforms.

To build an Objective C development environment in windows, download the four software packages from the gnustep Official Website: gnustep msys system, gnustep core, gnustep devel, and Cairo backend. The first two software packages must be installed. The third software package is to install some development tools, such as GCC and G ++. Therefore, if you are learning objective C, this package must also be installed. The fourth package is to install libraries such as glib. The installation of this package is not based on the actual situation. It is not recommended that the installation path contain Chinese characters. After installation, add the following to the environment variable path: C: \ gnustep \ System \ tools; C: \ gnustep \ bin; C: \ gnustep \ mingw \ bin. After installation, run the gnustep shell, that is, the msys in the installation directory. BAT. Test the GCC and make commands.

Test procedure

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;
7 }

Compile Link

1: directly compile the link using gcc

Gcc-O test. m-I/gnustep/system/library/headers-L/gnustep/system/library/Libraries-lobjc-lgnustep-base-fconstant-string-class = nsconstantstring

Where:

-I/gnustep/system/library/headers indicates the header file inclusion directory during compilation.

-L/gnustep/system/library/libraries indicates the connected Library File

-The lobjc link property does not need to be shown in the libobjc. A library. GCC will complete these tasks after receiving this link property.

-Fconstant-string-class = nsconstantstring: Specify the constant string type as nsconstantstring.

2: gnumakefile Mode

Write gnumakefile as follows:

  GNUSTEP_MAKEFILES=/GNUstep/System/Library/Makefiles
  include $(GNUSTEP_MAKEFILES)/common.make
  TOOL_NAME = test
  test_OBJC_FILES = ./main.m
  include $(GNUSTEP_MAKEFILES)/tool.make

Note: tool_name is defined as the project name test, test_objc_files to define the compilation file list.

Run the make command in the gnumakefile directory to obtain the executable file.

3: Use codeblocks with IDE

Compiler settings

Use the GCC installed with gnustep in the C: \ gnustep \ bin directory.

1)Settings-> compiler and debugger...

2) SelectGNU gcc CompilerClick Copy to rename it, for example"GNU gcc obj-C Compiler"

3) SetGNU gcc CompilerOfToolchain executablesThe path is c: \ gnustep \ bin, that is, the GCC directory of gnustep.

4)Compile settings->Other optionsAdd-fconstant-string-class = nsconstantstring

5)Linker settings->Other link options-Lobjc-lgnustep-base option.

If a problem occurs, you can use another method to remove the-lobjc-lgnustep-base option.Linker settings-> Link Libraries:

C:/gnustep/system/library/libraries/libobjc. dll.

C:/gnustep/system/library/libraries/libgnustep-base.dll.a

6) search directories-> complier adds the header file directory: C: \ gnustep \ System \ library \ Headers

 

Support for adding source file formats 1) environment... ,Select Files extension handlingAdd *. MAnd *. Mm 2) Project-> Project tree, File Types & categories... In Source*. M and *. MM highlighted 1) Settings-> Editor-> Syntax highlighting

2) SelectFilemasks ...,Add *. M and *. Mm

3) SelectKeywords...AddKeywordsTo the list box

Keywords:

@interface @implementation @end @class @selector @protocol @public @protected @private id BOOL YES NO SEL nil NULL self
 
Set to compiled Link 1) Right-click the. M file and choose Properties. 

2) Select build and selectCompile FileAndLink file

3) select general to removeFile is read-onlySelected

4) Note:. h fileNoSetCompile FileAndLink file

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.