如何在windows下用独立的MingW编译一个objective c程序

发布于 2024-09-15 05:39:07 字数 664 浏览 2 评论 0原文

我知道如何使用 mingw 的 gnustep 版本编译目标 c 程序。

但我不喜欢他们的 shell,我想使用标准的 mingw gcc 编译器。

当然,我将此 gcc bin 目录放在环境路径中,在 helloworld.m 目录中打开命令提示符

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

并键入,

gcc -o hello hello.m -I /GNUstep/System/Library/Headers -L /GNUstep/System/Library/Libraries -lobjc -lgnustep-base -fconstant-string-class=NSConstantString

但它不起作用,因为它找不到 Foundation/foundation.h

如何解决此问题,如果可能的话,避免在 hello 源中进行硬编码代码 ?

I know how to compile the objective c program using gnustep version of mingw.

But I don't like their shell and I want to use the standard mingw gcc compiler.

I put this gcc bin directory in environment path of course, open command prompt in my helloworld.m directory

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

and type

gcc -o hello hello.m -I /GNUstep/System/Library/Headers -L /GNUstep/System/Library/Libraries -lobjc -lgnustep-base -fconstant-string-class=NSConstantString

but it doesn't work because it cannot find foundation/foundation.h

How to fix this and if possible avoid hardcoding in hello source code ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

如梦初醒的夏天 2024-09-22 05:39:07

请查看此处博主说要写的帖子结尾:

gcc `gnustep-config --objc-flags` -o hello2 hello2.m -L /GNUstep/System/Library/Libraries -lobjc -lgnustep-base

看来你总是必须通过GNUStep

Have a look here at the end of the post the blogger says to write:

gcc `gnustep-config --objc-flags` -o hello2 hello2.m -L /GNUstep/System/Library/Libraries -lobjc -lgnustep-base

It seems like you always have to pass through GNUStep

南笙 2024-09-22 05:39:07

我遇到了同样的问题。像下面这样修改命令行解决了我的问题。

gcc -I"c:/GNUstep/GNUstep/System/Library/Headers" -L "c:/GNUstep/GNUstep/System/Library/Libraries" -o hello hello.m -lobjc -lgnustep-base -fconstant-string-class=NSConstantString

I had the same problem.Modifying command line like below solved my problem.

gcc -I"c:/GNUstep/GNUstep/System/Library/Headers" -L "c:/GNUstep/GNUstep/System/Library/Libraries" -o hello hello.m -lobjc -lgnustep-base -fconstant-string-class=NSConstantString
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文