Rahul Vyas
Rahul Vyas

Reputation: 28720

how to compile iphone code using makefile?

I want to compile an iPhone app using make command. But it always shows error

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

Here are the makefile contents.

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

How do i compile my app. I am not familiar with unix commands. So please guide me step by step.

Update

Now getting error after changing paths.

                 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

Upvotes: 4

Views: 4418

Answers (1)

Kay
Kay

Reputation: 13146

Replace /opt/iphone/ by /Developer/Platforms/iPhoneOS.platform/Developer/usr/ or whereever your gcc is located. If I look into my bin sub-directory there is no arm-apple-darwin-gcc but a arm-apple-darwin10-llvm-gcc-4.2.

Open a terminal and type

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

ls bin/

Now you will see a list of compilers available on your system. BTW: I don't have an addons directory so I guess it is part of some special software package you have installed.

[Update]: Following flags are set in 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.platform/Developer/SDKs/iPhoneOS4.2.sdk -gdwarf-2 -mthumb -miphoneos-version-min=4.2

I don't know that much about the details of every flag, but it's worth a try to set them in CC within your makefile.

Upvotes: 6

Related Questions