Compile C applications with gcc on iOS 4 (iPhone)

I search a lot on internet how to do this, and I found some info from Anastas Stoyanovsky. Most people posted that if you install libgcc on iOS 4 it will crash at boot but this is not true.

Here is what you need to do in order to be able to compile and run a C application on iphone:

1. You will need to Jailbreak the iPhone first, search on google for more info.
2. Install OpenSSH from Cydia.
3. Connect iPhone to your wireless network and SSH to it.
4. Download this application using: wget
5. Install libcc using: dpkg –i fake-libgcc_1.0_iphoneos-arm.deb
6. Install iphone-gcc using this command: apt-get install iphone-gcc
(you can download this version from my website: iphone-gcc if does not work on your device the one that is installed by default)
7. Download using: wget
8. Untar with command: tar -xvzf sdk-2.0-headers.tar.gz
9. Enter in the new created folder with: cd include-2.0-sdk-ready-for-iphone
10. Copy all files to include folder with command: cp –r * /usr/include
11. Now type: cd .. in order to return to the previous folder
12. Download using: wget
13. Untar with command: tar -xvzf gcc_files.tar.gz
14. Enter in the new created folder with command: cd gcc_files
15. Copy all files to /usr/lib using command: cp –r * /usr/lib
16. Install ldid to sign the application (this will prevent iOS to kill the application at startup) using: apt-get install ldid
17. Sign your compilet aplication using: ldid –S <application>
18. Run the application using: ./<application>

For iOS 7.x if you get errors installing gcc, try this patched version:

4.1 wget
4.2 dpkg -i iphone-gcc_4.2-20080604-1-8p_iphoneos-arm.deb

Suggestion: Install using: apt-get install nano
This will help you code easy directly from terminal.

Here is an example of hello world using C and gcc to compile on iPhone iOS 4:

I used nano hello.c in terminal to open a new files and writed this simple application:

#include <stdio.h>
int main()
printf(“hello, world\n”);
return 0;

and then CTRL+X to save it, then I typed: gcc –o hello hello.c and after that ldid –S hello
Now you can run your application using ./hello


Related Posts
Leave a comment ?


  1. I’ve tried to build some UNIX software from src. I assume the software (specifically, a more modern edition of git to get the place of the obsolete .deb available on cydia) should build, but ./configure says gcc cannot produce any output, even if I’m root. Any idea on how should I came out of this?

  2. I figured out one thing: can anyone try to build an edition of macports for iOS? Obviously not all the ports can interface themselves on iDevices (I’m pretty sure Qt cannot, with many others), but littler and lighter software could be useful to make iDevices more UNIX-alike. Unfortunately, I don’t own one, but a friend has asked me if I could build him something like this on a mac.

  3. I used i-Fun box and iFile to install and move all the files that I need, (cuz I dont remember the pass of my SSH. And I use MobileTerminal.

    All was ok, but when I tried to do “apt-get install ldid”, it says:
    -sh: apt-get_ command not found.

    What can i do?

  4. After google it I found the solution: First install from cydia Aptbackup

  5. Does it compile C++? Cuz I’m getting some errors.

  6. Thank you!
    Works perfect

  7. Have you tried compiling objective c? I get an error

    ld: library not found for -lobjc
    collect2: ld returned 1 exit status
    make: *** [HelloWorld] Error 1

    It seems that iphone-gcc does not come with objective c support

  8. thank you!!!

  9. I can’t thank you enough for this, it has made hours of searching finally end favorably!

  10. Thank you! Works great. Any chance of including gfortran as well?

  11. Thanks! Works great! Any chance to include gfortran as well?

  12. Rooted Android vs jailbroken iPhone - Android Forums - pingback on March 5, 2012 at 01:26
  13. Srinivas Palavarapu

    Will the above tutorial work on ipad2 with iOS5 ?? ..

    please some one inform

  14. I’m getting errors in the studio.h header

  15. This rules. Can one link to the full framework toolchain?

  16. It worked on the iPad2 with ios5.
    Thanks a lot, great tutorial !

  17. Thank you !~~
    Finding libSystem.B.dylib everywhere……

  18. Work like a charm!

    Thanks a lot.

  19. You can install Gcc in Cydia too just after install, and when compiling don’t forget to sign your app withing an iPad/2/iPhone by
    compiling: gcc -o outPutName AppName.c
    signing : ldid -S outPutName
    Runing: ./outPutName

  20. GCC in iOS - nonocast - pingback on August 7, 2012 at 19:10
  21. Ipad 2, ios 5.1.1 and this worked great. Thank you

  22. ipad ios 5.1.1 – hello world works at least :-)


  23. thanks so much, your guide turned the process from nightmarish to a kid’s game :)

    have a good day

  24. @Matt … studio.h??? That may be your error. It’s stdio.h. :)

  25. The libstdg++.dylib is missing in the fake libgcc,hence cant compile c++.can u give any solution,please?thanks in advance.

  26. libgcc_s_6 is not found by ld/as
    any idea where to get one?

  27. thanks worked finally yay

    I spent 10 hours and 2 nights trying to get it’s going before I found your site I wwas about to give up!

  28. @Darius, glad this post helped you.

  29. Hello,

    Trying to get this to work on my iPod Touch 4th Gen. It has an A4 (armv7) processor, and when compiling I get the error:

    ld: unknown/unsupported architecture name for: -arch arm
    collect2: ld returned 1 exit status

    Am I doing something wrong? has anyone else had success with this on the iPod Touch 4G? Thanks for any advice.


  30. it shows many errors from stdio.h and string.h. and i can’t run c++ because it says permision denied ( access to /usr/include/c++)

  31. This all worked out great for me running ios 7.0.1 jailbreaked, my question is where do we go from here? ive tryed searching for an example gui hello world application written in c or c++ but have come up empty anyone got any suggestions?

  32. I run into problems when trying to install iphone-gcc on a jailbroken ipad running ios 7.1:

    “iPad-van-Niek:~ root# dpkg -i iphone-gcc_4.2-20080604-1-8_iphoneos-arm.deb
    Selecting previously deselected package iphone-gcc.
    (Reading database … 1278 files and directories currently installed.)
    Unpacking iphone-gcc (from iphone-gcc_4.2-20080604-1-8_iphoneos-arm.deb) …
    dpkg: dependency problems prevent configuration of iphone-gcc:
    iphone-gcc depends on csu; however:
    Package csu is not installed.
    iphone-gcc depends on odcctools; however:
    Package odcctools is not installed.
    dpkg: error processing iphone-gcc (–install):
    dependency problems – leaving unconfigured
    Errors were encountered while processing:

  33. @dohduhdah please try before installing gcc

    dpkg -i csu_232-2_iphoneos-arm.deb

    dpkg -i odcctools_286-8_iphoneos-arm.deb

  34. Oh, I see I need a patched version of gcc found here:

  35. @Sergiu: It looked like the patched version of gcc installed ok. Is it ok to install csu and odcctools afterwards or is it critical to install those first?

    when I run gcc, it no longer gives an “illegal instruction: 4” error.

  36. @dohduhdah

    don`t know, no iphone where to test. If you install, i`ll update the post based on your experience on iOS 7

  37. Well, it looks like the gcc (patched for ipad4) is working. It installed without errors and it seems to run ok.

  38. You can also install CppCode – offline C/C++ IDE & Compiler on iOS. No internet connection, no jailbreak required, code complete supported! Visit

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>