Tutorial – Installing gcc compiler on iPhone

This Tutorial needs headers and libraries from Mac OSX.
  1. Make sure the following applications are installed from Cydia.
    1. Mobile Terminal
    2. Safari Download Plugin
  2. Open Safari and open the following link (It was written by Ryan Petrich):
    http://files.eagos.net/fake-libgcc_1.0_iphoneos-arm.deb
  3. Open MobileTerminal app on iPhone
  4. Type in “dpkg -i /var/mobile/Library/Downloads/fake-libgcc_1.0_iphoneos-arm.deb”
  5. Open Cydia and install “GNU C Compiler”, “C++ Standard Library”, and “ldid”.
  6. Now you need the headers and libraries. (Can’t upload files because of  copyright issues)
    1. Make sure you have the iPhone SDK installed  on you Mac OSX.
    2. Go to the following folder /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.2.sdk/usr/lib
    3. Use Diskaid or other iphone browsers to copy all the files to iPhone to directory
      /var/mobile/Documents/lib
    4. Now we have to link it to /usr/lib/lib/
      (The headers and libraries are huge so it’s better to store them in the larger partition and then link it in the system partition.)
    5. On iPhone, open Mobile Terminal and type in “ln -s /var/mobile/Documents/lib /usr/lib/lib”
    6. Go to the following folder
      /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.2.sdk/usr/include/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.2.sdk/usr/include
      /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.2.sdk/usr/include
    7. Use Diskaid or other iphone browsers to copy all the files to iPhone to directory /var/mobile/Documents/include
    8. Now we have to link it to /usr/include/incl
      (The headers and libraries are huge so it’s better to store them in the larger partition and then link it in the system partition.)
    9. On iPhone, open Mobile Terminal and type in “ln -s /var/mobile/Documents/include /usr/include/incl”
  7. Now you need to know how to compile.
    1. Open Mobile Terminal on iPhone
    2. Type the following for iostream support.
      g++ (input.cpp) -o (output) -I/usr/include/incl/c++/4.2.1/ -I/usr/include/incl -I/usr/include/incl/c++/4.2.1/armv7-apple-darwin9/ -I/usr/lib/lib/gcc/arm-apple-darwin9/4.2.1/include/ -L/usr/lib/lib/
    3. Now you need to sign the code.
      Type on iPhone Terminal: ldid -S (output)
    4. Now run your application.