使用 Makefile 编译 Objc 项目
我正在尝试制作跨平台游戏并创建项目(http://cl.ly/5QRn)。我试图做到这一点,但得到:
Mark-Fedurins-iMac:Evolve hitecnologys$ make
gcc -g -c -o OSX/AppDelegate.o OSX/AppDelegate.m
gcc -g -c -o OSX/osx.o OSX/osx.m
gcc -g -c -o main.o main.m
In file included from OSX/osx.m:2,
from main.m:6:
OSX/AppDelegate.m: In function ‘main’:
OSX/AppDelegate.m:4: error: expected expression before ‘interface’
In file included from main.m:6:
OSX/osx.m:10: error: expected expression before ‘end’
main.m:8: error: ‘app’ undeclared (first use in this function)
main.m:8: error: (Each undeclared identifier is reported only once
main.m:8: error: for each function it appears in.)
make: *** [main.o] Error 1
我做错了什么?请回答这个愚蠢的白痴他应该做什么:) 谢谢!
I'm trying to make crossplatform game and created project(http://cl.ly/5QRn). I'm trying make it but get:
Mark-Fedurins-iMac:Evolve hitecnologys$ make
gcc -g -c -o OSX/AppDelegate.o OSX/AppDelegate.m
gcc -g -c -o OSX/osx.o OSX/osx.m
gcc -g -c -o main.o main.m
In file included from OSX/osx.m:2,
from main.m:6:
OSX/AppDelegate.m: In function ‘main’:
OSX/AppDelegate.m:4: error: expected expression before ‘interface’
In file included from main.m:6:
OSX/osx.m:10: error: expected expression before ‘end’
main.m:8: error: ‘app’ undeclared (first use in this function)
main.m:8: error: (Each undeclared identifier is reported only once
main.m:8: error: for each function it appears in.)
make: *** [main.o] Error 1
What I do wrong? Please answer the stupid idiot what he should do :)
Thx!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先 - 为什么要 #import'ing .m 文件? #import 用于头文件 (.h)。其次,这只是一个语法错误,与您使用 makefile 的事实无关,因此您的主题行选择错误。它的拼写是“@interface”,而不是“interface”。同样,在 main.m 中,您使用了一个尚未声明的名为“app”的变量。
一般来说,听起来你需要阅读语言教程 - 你不能只是编造一些东西并期望编译器理解它。
http://developer.apple.com/library/ mac/#referencelibrary/GettingStarted/Learning_Objective-C_A_Primer/_index.html
First of all - why are you #import'ing .m files? #import is for header (.h) files. Second, this is just a syntax error, nothing to do with the fact you're using a makefile, so your subject line is badly chosen. It's spelled "@interface", not "interface". Likewise, in main.m, you're using a variable named "app" which you haven't declared.
In general, it sounds like you need to read a language tutorial - you can't just make stuff up and expect the compiler to understand it.
http://developer.apple.com/library/mac/#referencelibrary/GettingStarted/Learning_Objective-C_A_Primer/_index.html