How to compile an objective c program under windows with independant MingW

若如初见. 提交于 2019-12-01 09:08:14

问题


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 ?


回答1:


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




回答2:


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


来源:https://stackoverflow.com/questions/3538051/how-to-compile-an-objective-c-program-under-windows-with-independant-mingw

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!