iphone - 如何使用makefile编译iphone代码?

标签 iphone gcc makefile compiler-errors

我想使用 make 命令编译 iPhone 应用程序。但总是显示错误

make: /opt/iphone/bin/arm-apple-darwin-gcc: No such file or directory
make: *** [src/main.o] Error 1

这是 makefile 的内容。

CC=/opt/iphone/bin/arm-apple-darwin-gcc \
    -isysroot /opt/iphone/addons/1.0.2/system \
    -isystem /opt/iphone/include \
    -isystem /opt/iphone/include/gcc/darwin/3.3 \
    -F/opt/iphone/addons/1.0.2/system/System/Library/Frameworks

我如何编译我的应用程序。我对unix命令不熟悉。所以请逐步指导我。

更新

更改路径后出现错误。

                 from /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOs4.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:10,
                 from /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOs4.2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:9,
                 from /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOs4.2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:9,
                 from src/main.m:23:
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOs4.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h: At top level:
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOs4.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:15: error: syntax error before ‘BOOL’
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOs4.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:16: fatal error: method definition not in @implementation context
compilation terminated.
make: *** [src/main.o] Error 1

最佳答案

将/opt/iphone/替换为/Developer/Platforms/iPhoneOS.platform/Developer/usr/或您的 gcc 所在的位置。如果我查看我的 bin 子目录,则没有arm-apple-darwin-gcc,而是arm-apple-darwin10-llvm-gcc-4.2。

打开终端并输入

cd/Developer/Platforms/iPhoneOS.platform/Developer/usr

ls bin/

现在您将看到系统上可用的编译器列表。顺便说一句:我没有插件目录,所以我猜它是您安装的某些特殊软件包的一部分。

[更新]: XCode 中设置了以下标志:

-x Objective-c -arch armv7 -fmessage-length=0 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -O0 -Wreturn-type -Wunused-variable -isysroot/Developer/Platforms/iPhoneOS。平台/开发者/SDKs/iPhoneOS4.2.sdk -gdwarf-2 -mthumb -miphoneos-version-min=4.2

我不太了解每个标志的详细信息,但值得尝试在 makefile 中的 CC 中设置它们。

关于iphone - 如何使用makefile编译iphone代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6452381/

相关文章:

c - 用汇编语言解释这一行?

linux - 用arm-linux-xxx-gcc编译的用户程序运行在x86机器上?

makefile - 在 makefile 中指定重建策略

iphone - 在我的应用程序中实现 iPhone 相机中的 Flash 按钮动画?

c++ - 我们什么时候应该使用 RTLD_DEEPBIND?

ios7 所有 searchviews 和 tableviews 关闭 20 像素

linux - C linux 中的 Makefile 错误

c - 为什么 make 会重新编译该 makefile 中的所有内容?

ios - 如何提交在iPhone OS 3和iPhone SDK 4上运行的应用程序版本?

iphone - 无法通过 SSL 进行无线 iOS 分发?