【问题标题】:how to compile iphone code using makefile?如何使用makefile编译iphone代码?
【发布时间】:2011-09-21 02:19:11
【问题描述】:

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

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

这里是生成文件的内容。

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

【问题讨论】:

    标签: iphone gcc makefile compiler-errors


    【解决方案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 目标-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 中设置它们。

    【讨论】:

    • 非常感谢您提供有用的信息。但现在我遇到了另一个错误。查看问题的更新
    • 听起来编译器不了解 Objective-C 的基础知识。我复制了调用的一部分,就像 XCode 在构建时执行它一样。在答案中查看我的更新
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-04
    • 2014-11-05
    • 2019-07-11
    • 1970-01-01
    • 1970-01-01
    • 2012-04-09
    相关资源
    最近更新 更多