Windows下配置Objective-C開發環境

來源:互聯網
上載者:User

標籤:lease   link   整合開發   配置   debug   argv   不同   block   裝包   

一、IDE的安裝(Code::Blocks)

我們選用Code::Blocks作為IDE,它的安裝包可以從網上各處下載下來,對版本無特別要求。筆者使用的是16.10的版本(連結: https://pan.baidu.com/s/1l7EtMVWBCffuCVHaF3-tQg 密碼: 85ie)

具體安裝細節我就不寫了。

二、編譯工具的安裝(GNUStep)

我們需要如下的六個安裝包:

ProjectCenter-0.5.0-setup.exe(http://ftp.gnustep.org/pub/gnustep/binaries/windows/ProjectCenter-0.5.0-setup.exe)

gnustep-cairo-0.22.0-setup.exe(http://ftp.gnustep.org/pub/gnustep/binaries/windows/gnustep-cairo-0.22.0-setup.exe)

gnustep-core-0.22.0-setup.exe(http://ftp.gnustep.org/pub/gnustep/binaries/windows/gnustep-core-0.22.0-setup.exe)

gnustep-devel-1.4.0-setup.exe(http://ftp.gnustep.org/pub/gnustep/binaries/windows/gnustep-devel-1.4.0-setup.exe)

gnustep-system-0.22.0-setup.exe(http://ftp.gnustep.org/pub/gnustep/binaries/windows/gnustep-system-0.22.0-setup.exe)

gorm-1.2.8-setup.exe(http://ftp.gnustep.org/pub/gnustep/binaries/windows/gorm-1.2.8-setup.exe)

注意:都要安裝的一個檔案夾,如:D:\GNUStep。

三、IDE的配置

好的我們要進入本文了。

首先,啟動Code::Blocks。進入Settings->Compiler and Debugger...,選擇GNU GCC Compiler編譯器,按“Copy”按鈕,並重新命名為“GNUstep MinGW Compiler“並儲存。之後進入Other Options 分頁,輸入:  -fconstant-string-class=NSConstantString -std=c99

接下來, 

連接器設定 Linker stettings

在串連庫(Link Libraries)中添加兩個檔案:

D:\GNUstep\GNUstep\System\Library\Libraries\libobjc.dll.a
D:\GNUstep\GNUstep\System\Library\Libraries\libgnustep-base.dll.a

可能你的安裝地址和我的不同,那樣的話可以改一下上述地址。

之後在指定搜尋目錄Search directories:Compiler(編譯器)設定為D:\GNUstep\GNUstep\System\Library\Headers

然後,添加Objective-C檔案類型支援:進入Settings->Environment...,選擇 Files extension handling 添加*.m, *.mm

再進入 Project->Project tree->Edit file types & categories... ,在Sources, 下面添加 *.m到檔案類型列表中,進入 Settings->Editor...,選擇 Syntax highlighting,點擊“Filemasks....”按鈕,在彈出框尾部添加*.m , *.mm到檔案類型。

點擊C/C++,在下拉框中選擇Objective C。

四、測試

建立工程,選擇Empty Project。之後建立檔案 -> Empty File。儲存為main.m(注意尾碼名為*.m)。

輸入代碼:

#import <Foundation/Foundation.h>int main (int argc, const char *argv[]){    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];    NSLog(@"hello world");    [pool drain];    return 0;}

之後構建(Build)並運行(Run)。

如果出現一個顯示“hello world"的視窗,恭喜你,你已經成功搭建了Windows下的Objective-C的整合式開發環境。

Windows下配置Objective-C開發環境

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.