如何使用独立的MingW在Windows下编译目标C程序 [英] How to compile an objective c program under windows with independant MingW

查看:124
本文介绍了如何使用独立的MingW在Windows下编译目标C程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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

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

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;
}

然后输入

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

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

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

推荐答案

看看

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

似乎您总是必须通过GNUStep

It seems like you always have to pass through GNUStep

这篇关于如何使用独立的MingW在Windows下编译目标C程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆