`
sogotobj
  • 浏览: 620882 次
  • 性别: Icon_minigender_2
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

在Windows上使用GNUstep和Objective-C

阅读更多
In addition to using Objective-C on a Mac system, it is also possible to download and install the GNUstep and Objective-C environments for Microsoft's Windows family of operating systems. In this chapter we will explore the steps involved in downloading, installing and testing both Objective-C and GNUstep on Windows.

Contents

[hide]
Downloading the GNUstep Packages

The GNUstep environment is made available on Windows using a toolkit called MinGW. MinGW is an abbreviation ofMinimal GNU for Windows and essentially provides a port of the GNU compiler collection, including Objective-C support, and a minimal shell environment for Windows platforms. Installation of GNUstep involves installing both MinGW and GNUstep. Both of these packages are available from the GNUstep web site at http://www.gnustep.org/experience/Windows.html.

The MinGW package is contained in the GNUstep System download and the GNUstep core is contained, unsurprisingly, in theGNUstep Core download. Both must be downloaded before proceeding with the installation.

[edit]Installing MinGW and GNUstep on Windows

Once the required packages have been downloaded, locate the GNUstep System file and launch it to initiate the installation process. To complete the installation, simply follow the prompts in the installation wizard, using the default installation settings unless you have specific requirements. In particular, should you decide to install the package in a location other than C:\GNUstep, you will need to adjust the instructions in the remainder of this chapter accordingly.

<style type="text/css"> <!-- --> </style>

Installing Objective-C on Windows


Once MinGW is installed, repeat the process for the GNUstep Core package.

[edit]Running the GNUstep Shell

To begin using Objective-C and GNUstep, start the GNUstep shell by selecting Start -> All Programs -> GNUstep -> Shell. Once loaded, the shell will appear as follows:

<style type="text/css"> <!-- --> </style>

The GNUstep shell running on Windows

[edit]Testing the Installation

The shell environment is a minimalist version of the shell environment you might find on a Linux or Unix system. If you are unfamiliar with such an environment then it is unlikely you will want to perform the code editing in this window. Fortunately, it is still possible to use your favorite editor on Windows.

When the shell is first started, it places you in the home directory for the GNUstep/MinGW environment. In terms of the Windows file system, and assuming you used the default installation location for MinGW and GNUstep, this is equates to:

C:\GNUstep\home\<username>

Where <username> is the name by which you logged into the Windows system. To create a simple application, open a suitable editor (Notepad will do) 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;
}

Once the code has been entered, save the file in your GNUstep home directory (as outlined above) ashello.m. If you used Notepad, be sure to switch the Save as Type option toAll Files so that the file is not given a .txt file name extension.

Once the code has been written and saved, it can be compiled from the GNUstep shell window by entering the following command:

$ gcc `gnustep-config --objc-flags` -L /GNUstep/System/Library/Libraries hello.m -o hello -lgnustep-base 
-lobjc

Assuming a successful compilation, run the application as follows:

./hello.exe

When executed, the test program should produce output similar to:

2009-09-24 14:31:25.721 hello[2200] hello world
分享到:
评论

相关推荐

    Clang GNUstep Objective C for Windows

    可以使用GNUstep在Windows XP上寫Objective-C程式,但是Objective-C已經加了很多新東西,而GNUstep裡的gcc並不提供,所以,这个是GNUstep,再加上新一代的編譯器架構Clang與LLVM(這也是Apple在新版Xcode裡預設使用...

    Windows7下编译运行Objective-C

    GNUstep之前只能在XP上实现编译运行Objective-C,而现在可以在Windows7上实现了,参见方法。

    Windows XP 系统下创建 Objective-C 集成开发环境

    本文档图文并茂的给出了如何在Win XP下创建 GNUstep + CodeBlocks 的Objective-C集成开发环境,测试成功,供参考!

    GNUStep入门教程(中文)

    GNUstep 使用 Objective-C 語言, 是 C 語言加上 SmallTalk 的物件導向的功能. 結合兩者的優點, 又不至於像 C++ 如此複雜. GNUstep 提供兩個主要的程式庫, Foundation 及 AppKit. Foundation 處理非圖形介面的部份, ...

    Subjective:适用于 Windows 的 Objective-C 2.0(非 GUI,32 位)- 已停产

    它允许您使用 LLVM/clang 编译器并在 Windows 上享受 Objective-C 语言的大多数最新功能。 但是,它不提供 GUI 层。 主观基于 GNUstep libobjc2 和 GNUstep Base。 这些子模块是它们各自源代码库的稍微修改的分支。...

    tools-windows-msvc:GNUstep Windows MSVC工具链

    然后,可以使用该工具链在任何Windows应用程序中集成Objective-C代码(无需使用MinGW)。图书馆该工具链当前包含以下库: (基础) (使用gnustep-2.0运行时) (Apple官方发布的Swift Core库)建设先决条件构建工具...

    GNUstep_core

    GNUstep Windows Installer提供了Windows平台下的Objective-C的模拟开发环境

    Cocoa Design Patterns

    作者:Erik M. Buck, Donald A....《Cocoa设计模式》中的许多信息同样也适用于Linux和Windows上的开源项目GNUStep。另外,Objective. C、C语言、C++和Java程序员都可以从《Cocoa设计模式》中获益。

    MyPsychro:CLI湿度计计算器

    它可以在Windows和OS X上成功运行,现已被Linux使用。 依存关系 Psychrometrics C / C ++库(从下载) Mac OS X 应该在开有Xcode的Mac OS X上进行编译。 Linux 建立基本要素 Gnustep Gnustep-devel 提供了一个...

    635026994501562500.rar_Windows编程_Visual_C++_

    Objective-C,通常写作ObjC和较少用的主要使用于Mac OS X和GNUstep这两个使用OpenStep标准的系统,而在NeXTSTEP和OpenStep中它更是基本语言

Global site tag (gtag.js) - Google Analytics