1

我知道以前有人问过这些问题,但一切都建议使用 GNUStep。有没有办法在没有 GNUStep 的情况下使用 Foundation?这对我来说也是一个学习问题(比如是否可以通过链接文件或其他东西来完成)

我安装了 Cygwin 和 gcc。我从 CocoaTron 获得了所有库,如下所示:http ://code.google.com/p/cocotron/source/browse/

我将库文件夹添加到 OBJC_INCLUDE_PATH 和 C_INCLUDE_PATH 中,它不再抱怨找不到 Foundation.h。

但我收到其他错误,例如:

$ gcc intro.m -o intro
In file included from /cocoa/CoreFoundation/CFBase.h:144,
                 from /cocoa/CoreFoundation/CFAttributedString.h:8,
                 from /cocoa/CoreFoundation/CoreFoundation.h:42,
                 from /cocoa/Foundation/Foundation.h:37,
                 from car.h:1,
                 from intro.m:2:
/cocoa/CoreFoundation/CFString.h:88: error: parse error before "va_list"
In file included from /cocoa/Foundation/NSAffineTransform.h:9,
                 from /cocoa/Foundation/Foundation.h:41,
                 from car.h:1,
                 from intro.m:2:
/cocoa/Foundation/NSGeometry.h:9:32: Foundation/NSObject.h: No such file or directory
In file included from /cygdrive/d/Allebrum Resources/C Libraries/cocoa/Foundation/NSAffineTransform.h:9,
                 from /cygdrive/d/Allebrum Resources/C Libraries/cocoa/Foundation/Foundation.h:41,
                 from car.h:1,
                 from intro.m:2:

对于新手问题,我很抱歉,我只是对运行一些测试感兴趣并且不想安装 GNUStep。

我的意思是,一个非常简单的例子,比如:

//car.h
#import <Foundation/Foundation.h>
@interface Car : NSObject{
}
- (void)addGas;
@end

#include <stdio.h>
#import "car.h"

int main(int argc, const char * argv[]){
printf("Hello");
return 0;
}  

是的,我知道这个例子不需要 objC ;) 我只是想跟着教程一起学习。

谢谢您的帮助!

4

1 回答 1

2

查看Cocotron的需求页面通用信息页面,好像只支持Mac上的开发。它提供的是在您的 Mac 上构建与 Windows 或 Linux 兼容的产品的能力。

所以,据我所知,目前还不能使用 Cocotron 在 Windows 上进行开发。您仍然必须使用 GNUstep。

于 2011-11-26T19:43:13.760 回答