Search code examples
xcodegccinclude-path

How to compile a C program that uses a Framework without using Xcode


I have a C command line tool written in Xcode that uses the Accelerate Framework. It builds and runs as expected from Xcode. But when I try to compile it from the command line (using gcc), I get the error: "Accelerate/Accelerate.h: No such file or directory". I don't know if adding the location of Accelerate.h to C_INCLUDE_PATH is the best way to fix this. Is there a better way ?


Solution

  • Try adding -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk and then link with UIKit framework -framework UIKit.

    You can check the actual build command line in Xcode build logs (option-7 in Xcode 4). Copy the one you need and adjust as required.

    Also, build it with xcodebuild tool. It will find everything automatically like Xcode does.