標籤: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開發環境