我正在編譯我的第一個Objective-C程序。這只是簡單的「編程很有趣!」代碼:編譯Objective-C程序時出錯
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSLog (@"Programming is fun!");
[pool drain];
return 0;
}
我下載了GNUstep的,MSYS系統-0.30.0-setup.exe並GNUstep的核心-0.34.0-setup.exe並按照這個順序安裝它們。我將名爲prg1.m(包含前面的代碼)的文件複製到/GNUstep/msys/1.0/home/username文件夾中。我打開GNUstep的外殼,並着手發出以下命令:
gcc -o prg1 prg1.m -I /GNUstep/System/Library/Headers -L /GNUstep/System/Library/Libraries -lobjc -lgnustep-base -fconstant-string-class=NSConstantString
我得到以下輸出:
In file included from C:/GNUstep/GNUstep/System/Library/Headers/GNUstepBase/GSCo
nfig.h:281:0,
from C:/GNUstep/GNUstep/System/Library/Headers/GNUstepBase/GSVe
rsionMacros.h:219,
from C:/GNUstep/GNUstep/System/Library/Headers/Foundation/Found
ation.h:30,
from prg1.m:1:
c:\mingw\include\w32api.h:27:2: warning: #warning WARNING - The w32api.h header
file is deprecated and will be removed. [-Wcpp]
#warning WARNING - The w32api.h header file is deprecated and will be removed.
^
In file included from C:/GNUstep/GNUstep/System/Library/Headers/Foundation/NSPor
tMessage.h:30:0,
from C:/GNUstep/GNUstep/System/Library/Headers/Foundation/Found
ation.h:99,
from prg1.m:1:
C:/GNUstep/GNUstep/System/Library/Headers/Foundation/NSPort.h:210:3: error: unkn
own type name 'WSAEVENT'
WSAEVENT eventListener;
^
任何人都知道爲什麼,我在最後得到這個錯誤?我一直在Google上搜索幾個小時,但沒有多少運氣。任何幫助將不勝感激。提前致謝。
您是否曾經安裝過MinGW?我剛剛安裝了GNUstep MSYS System 0.30.0,GNUstep Core 0.34.0和GNUstep Devel 1.4.0,我無法重現你的問題。此行'c:\ mingw \ include \ w32api.h'不對應於我的安裝路徑:'C:GNUstep \ include \ w32api.h' – Emmanuel
就是這樣。現在我可以放棄對着牆壁的撞擊了。我之前曾在另一個文件夾中安裝了MinGw,並且我的Path語句指向它。謝謝一堆。 – TheGump
嘗試使用gnustep-make包進行構建。在GNUstep郵件列表上詢問是個好主意。 –