posts - 33, comments - 46, trackbacks - 0, articles - 2

          1、安裝編譯器   

          Objective-C的編譯器有很多,其中LLVM屬于從GCC發展出來的,主要使用在蘋果的平臺中,GNU可以使用GnuStep,網址是http://wwwmain.gnustep.org/,從這里可以下載Windows版本的gcc編譯器,配合codeblocks可以編譯調試object c程序。
             
          進入下載頁面,下載上面3個軟件包,安裝,例如安裝到D:\GNUstep,

          2、安裝CodeBlocks IDE環境

          下載地址:http://www.codeblocks.org/

          3、配置編譯器

          安裝好codeblocks之后,進入Settings->Compiler and debugger...,選擇GNU GCC Compiler編譯器,復制重新命名為“GNUstep MinGW Compiler“配置

            

          編譯其他選項錄入:-fconstant-string-class=NSConstantString -std=c99

          image

          同時指定搜索目錄:
          》編譯器的搜索目錄是D:\GNUstep\GNUstep\System\Library\Headers
          》linker的搜索目錄設置為D:\GNUstep\GNUstep\System\Library\Libraries,同時設置linker的參數:-lobjc -lgnustep-base
          或者可以在linker選項中加入D:\GNUstep\GNUstep\System\Library\Libraries下面的2個文件libgnustep-base.dll.a,libobjc.dll.a

          image

          image

          設置編譯器、連接器的搜索目錄

          image

          4、配置語法、文件類型,關鍵字等

          添加文件類型支持

          1) 進入Settings->Environment...

          2) 選擇 Files extension handling 添加*.m

          3) 進入 Project->Project tree->Edit file types & categories...

          4) 在Sources, 下面添加 *.m到文件類型列表中.

          image

          添加語法高亮支持

          1) 進入 Settings->Editor...

          2) 選擇 Syntax highlighting 進入Filemasks.... 添加*.m 到文件類型列表中.

          3) 進入 Keywords... (緊靠Filemasks...) 添加下面的關鍵字到列表中
          @interface @implementation @end @class @selector @protocol @public @protected @private id BOOL YES NO SEL nil NULL self

          語法高亮中,加入*.m擴展名
          image 

          5、代碼測試

          新建一個工程,修改main.c為main.m,錄入下面代碼

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

          編譯運行效果如下:

          2012-03-07 17:33:49.711 objc1[6080] hello world

          Process returned 0 (0x0)   execution time : 0.220 s
          Press any key to continue.

          Feedback

          # re: Windows環境下面搭建Object C開發環境  回復  更多評論   

          2012-03-18 11:08 by 天外的星星
          我前面都是那樣來配置的,但是最后新建工程不知道新建什么工程,然后編譯也沒什么反應啊。前面有設置.m文件時用什么編譯的嗎?

          # re: Windows環境下面搭建Object C開發環境  回復  更多評論   

          2012-04-23 10:01 by midea0978
          @天外的星星
          你可以檢查一下編譯日志,例如下面這樣的信息表明編譯成功
          使用gnustep編譯器會自動編譯*.m文件的
          -------------- 構建: Debug in objc1 ---------------

          正在編譯: main.m
          正在連接 控制臺可執行: bin\Debug\objc1.exe
          Output size is 157.96 KB
          過程結束,其狀態為 0 (0 分鐘, 6 秒)
          0 個錯誤, 0 個警告

          # re: Windows環境下面搭建Object C開發環境  回復  更多評論   

          2012-09-22 22:29 by

          正在編譯: main.m
          mingw32-gcc.exe: CreateProcess: No such file or directory
          過程結束,其狀態為 1 (0 分鐘, 0 秒)
          0 個錯誤, 0 個警告

          # re: Windows環境下面搭建Object C開發環境  回復  更多評論   

          2012-09-22 22:30 by
          為什么我編譯的時候會出現這個錯誤,怎么也不對,請指教,謝謝

          正在編譯: main.m
          mingw32-gcc.exe: CreateProcess: No such file or directory
          過程結束,其狀態為 1 (0 分鐘, 0 秒)
          0 個錯誤, 0 個警告

          # re: Windows環境下面搭建Object C開發環境[未登錄]  回復  更多評論   

          2012-11-28 16:28 by luke
          我也剛遇到樓上相同的問題
          我的解法是 單獨下載新的MinGW (http://sourceforge.net/projects/mingw/?source=dlp)
          ex.下載至C:\MinGW
          並將codeblock的compiler's installation directory指向 C:\MinGW\bin
          "mingw32-gcc.exe: CreateProcess: No such file or directory"
          便可解決

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 九江市| 津市市| 崇义县| 志丹县| 台安县| 吴江市| 高台县| 汶川县| 仁布县| 隆子县| 松潘县| 大洼县| 襄汾县| 柘荣县| 博野县| 荣昌县| 黎城县| 诸暨市| 鱼台县| 本溪| 博野县| 建德市| 灵山县| 马山县| 当雄县| 徐闻县| 凯里市| 泰兴市| 称多县| 文成县| 辽中县| 新绛县| 甘泉县| 无棣县| 兴城市| 六枝特区| 祁门县| 河间市| 高唐县| 皮山县| 博兴县|