无法使用Gnustep在Windows上编译目标C. [英] Unable to Compile Objective C using Gnustep on windows

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

问题描述

您好,我是一个初学者学习目标。
i我发现一个错误hello.m:1:34:Foundation / Foundation.h:没有这样的文件或目录
i知道我需要一个make文件
可能知道如何制作make文件请

解决方案

无需创建makefile。如果你从所有程序 - > GNUstep - > Shell启动MinGW,因为Pax表示上面,你只需要编译你的.m文件。



我的GNUstep安装位于c:\GNUstep\GNUstep\System。如果你不同,你应该相应地改变Foundation.h的导入。



我这样做:


  1. 创建c:\myprogs\obj-c\hello\hello.m,如下所示:

// ---------- Hello.m

  #import< ../ ../GNUstep/System/Library/Headers/Foundation/Foundation.h> 

int main(int argc,const char * argv [])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSLog(@Hello from Hello.m!);

[pool release];
return 0;
}

// ----------


  1. 启动MinGW shell。 (见上文)


  2. 在shell命令行中,切换到程序代码所在的目录。 (注意,由于这不是Unix,必须包括Windows驱动器号。):



    cd / c / myprogs / obj-c / hello


  3. 编译程式:



    gcc -o hello hello.m -I / c / GNUstep / GNUstep / System / Library / Headers \



    -L / c / GNUstep / GNUstep / System / Library / Libraries -lobjc -lgnustep-base \



    -fconstant-string-class = NSConstantString


字符允许我们将命令扩展到多行。)



我在编译时得到以下信息性消息:

 信息:通过链接到__imp____objc_class_name_NSAutoreleasePool(自动导入)
来解析___objc_class_name_NSAutoreleasePool通过链接到__imp____objc_class_name_NSConstantString(自动导入)
来解析___objc_class_name_NSConstantString
 <$ c $> c> 2009-06-03 14:44:59.483 hello [1240] Hello你好Hello! 


Hi i am a beginner learning objective c. i am finding an error "hello.m:1:34: Foundation/Foundation.h: No such file or directory" i came to know that i need to make a make file may i know how to make the make file please

解决方案

No need to create a makefile. If you start MinGW from "All Programs -> GNUstep -> Shell" as Pax indicates above, you can just compile your .m file.

My GNUstep installation is in c:\GNUstep\GNUstep\System. If yours is different, you should change the import of Foundation.h accordingly.

I did this:

  1. Create c:\myprogs\obj-c\hello\hello.m that looks like this:

//---------- Hello.m

#import <../../GNUstep/System/Library/Headers/Foundation/Foundation.h>

int main(int argc, const char* argv[])
{
    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
    NSLog(@"Hello from Hello.m!");

    [pool release];
    return 0;
}

//----------

  1. Start MinGW shell. (See above.)

  2. On shell command line, change to directory where program code is located. (Note that, since this is not Unix, the Windows drive letter must be included.):

    cd /c/myprogs/obj-c/hello

  3. Compile the program:

    gcc -o hello hello.m -I/c/GNUstep/GNUstep/System/Library/Headers \

    -L /c/GNUstep/GNUstep/System/Library/Libraries -lobjc -lgnustep-base \

    -fconstant-string-class=NSConstantString

(Note that "\" character allows us to extend command to multiple lines.)

I get the following informational messages when I compile:

Info: resolving ___objc_class_name_NSAutoreleasePool by linking to __imp____objc_class_name_NSAutoreleasePool (auto-import)
Info: resolving ___objc_class_name_NSConstantString by linking to __imp____objc_class_name_NSConstantString (auto-import)

Running resulting hello.exe gives me this:

2009-06-03 14:44:59.483 hello[1240] Hello from Hello.m!

这篇关于无法使用Gnustep在Windows上编译目标C.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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