Tutorial – Cross-compile using iPhone SDK

Mac OSX users only. iPhone sdk isn’t available on Linux and PC.

Compiling your code on the slow, in comparison, iPhone is not practical for huge projects. It is better to have the ability to compile the iPhone application on the computer and then send it to the iPhone because simply the computer is faster. That’s where cross-compilers come in. Cross-Compilers are tools that compile source codes for specific architectures on a foreign architecture such as compiling arm iphone code on intel based macs in this case.
The following are the steps to build an easy to use script to compile C/C++ iphone applications on the computer using the iPhone sdk built in cross-compilers.
  1. Download my bash code from the following website : http://pastie.org/702317
  2. Save it to a file name called g++_iphone
  3. chmod +x ./g++_iphone
  4. sudo cp ./g++_iphone /usr/bin/
  5. g++_iphone (input.cpp) (output name)
  6. Then send the compiled output to the iPhone.
  7. On iPhone terminal type: ldid -S (output name)
  8. Now you can run application by ./(output name)