Compile C Applications With GCC On iOS 4 (Iphone)
Compile C Applications With GCC On iOS 4 (Iphone)
HOME
I search a lot on internet how to do this, and I found some info from Anastas Stoyanovsky. @jcf_dev ipad1 and iphone 3gs
Most people posted that if you install libgcc on iOS 4 it will crash at boot but this is not true. 2011/03/22
1. You will need to Jailbreak the iPhone first, search on google for more info. Updated to iOS 4, nice release from
2. Install OpenSSH from Cydia. them, battery lasts longer now.
3. Connect iPhone to your wireless network and SSH to it. 2010/06/29
4. Download this application using: wget http://www.syshalt.net/pub/iphone/gcc-
iphone/fake-libgcc_1.0_iphoneos-arm.deb
Recent Posts
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 Disable iOS 4 services. Optimize your
(you can download this version from my website: iphone-gcc if does not work on your iPhone, iPod, iPad and save memory.
device the one that is installed by default)
7. Download using: wget http://www.syshalt.net/iphone/gcc-iphone/sdk-2.0- greenp0ison RC5 libcurl.4.dylib
headers.tar.gz “Incompatible library version:
8. Untar with command: tar -xvzf sdk-2.0-headers.tar.gz greenpois0n requires version 6.0.0”
9. Enter in the new created folder with: cd include-2.0-sdk-ready-for-iphone on OSX 10.5.8
10. Copy all files to include folder with command: cp –r * /usr/include
Install iOS 4.3b2 on iPad and jailbreak
11. Now type: cd .. in order to return to the previous folder
(tethered) – fully working
12. Download using: wget http://www.syshalt.net/iphone/gcc-iphone/gcc_files.tar.gz
13. Untar with command: tar -xvzf gcc_files.tar.gz Prevent Winmail.dat in mail
14. Enter in the new created folder with command: cd gcc_files attachment (Exchange 2007)
15. Copy all files to /usr/lib using command: cp –r * /usr/lib
Blue Screen of Death (BSOD) on
16. Install ldid to sign the application (this will prevent iOS to kill the application at
Windows 2000 Server
startup) using: apt-get install ldid
17. Sign your compilet aplication using: ldid –S <application>
18. Run the application using: ./<application> Friends
* Thanks for Liero, he found that it is a bug in latest version of gcc from Saurik, so he Andrada Misca
provided us with a version that works. Catalin
Cristian Crisan
Suggestion: Install using: apt-get install nano
This will help you code easy directly from terminal. Marian Neagul
Here is an example of hello world using C and gcc to compile on iPhone iOS 4:
Archives
I used nano hello.c in terminal to open a new files and writed this simple application: February 2011
December 2010
#include <stdio.h>
int main() October 2010
{
September 2010
printf("hello, world\n");
return 0; May 2010
}
March 2009
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 Categories
Apple
CentOS
…syshalt.net/…/compile-c-applications-w… 1/8
3/24/2011 Compile C applications with gcc on iOS 4…
Exchange 2003/2007
iPad
iPhone
Linux
Microsoft
Others
Windows 2000
Meta
Register
Log in
Entries RSS
Technorati Tags: ios4,jailbreak,iphone,apple,gcc,g++,programming,cydia,apt-get
Comments RSS
Tagged as: Anastas, c application, c applications, code, command cd, command cp, Leave a comment
command tar, Connect, cydia, deb, default, dpkg, gcc, google, include, info, WordPress.org
Install, int, ios, iphone, lib, Liero, lt, openssh, Saurik, sdk, search, startup,
suggestion, tar gz, terminal, type, type cd, Untar, wget
Statistics
Today visits: 32
Tags
Comments (28) Trackbacks (2) ( subscribe to comments on this post )
THANK YOU SO MUCH! I LUV U! NVM, BUT THANKS! redsn screen search system
library terminal test time
TinyUmbrella wheel windows c
geekstrada
October 15th, 2010 - 05:03
Nathan Broadbent
October 16th, 2010 - 13:36
Carlo
November 18th, 2010 - 16:09
Hello Sergiu.
Thanks a lot for your instructions on compiling C apps on iOS 4. Before I found your site, I
…syshalt.net/…/compile-c-applications-w… 2/8
3/24/2011 Compile C applications with gcc on iOS 4…
Thanks a lot for your instructions on compiling C apps on iOS 4. Before I found your site, I
had spent so much time on this issue without success. Great help probably not only for
me, but for all those in the community who get to know that compiling on iPhone 4 is
much more pleasure than on the weaker earlier models.
Hm, well… may I nevertheless dare to ask for an additional thing?: Do you know about
anybody working on something similar for C++? At least, all my efforts end up in linker
errors indicating libraries being missing.
James
November 28th, 2010 - 19:05
Thanks a lot
James
November 29th, 2010 - 04:39
Thanks Nathan~
I reinstall again and it works,
3L173 Darkra1gne
December 3rd, 2010 - 16:49
Good guide I like ur style. Fed up of people asking how it’s done about time sum1 took the
masses through it step by step. Now all we need is to come up with a way of developing a
step by step guide to creating new programs lol. And put Microsoft apple and all those
other software theefs out of business. Every 1 use unix Linux and say no to close source
inferia bs.
Erik Séguin
…syshalt.net/…/compile-c-applications-w… 4/8
3/24/2011 Compile C applications with gcc on iOS 4…
Erik Séguin
December 12th, 2010 - 06:57
Nikola
December 16th, 2010 - 01:08
@James: How you fixed the error (Ive done the hole process 2 times and it still gives me
the same errors when compiling…)
Thanks
Nikola
December 16th, 2010 - 01:13
was missing line “9. Copy all files to include folder with command: cp –r * /usr/include”
Qantum251
December 18th, 2010 - 15:49
Thanks thanks thanks…!i’ve been looking for that trick since i bought that bad phone but
now worth it, just one thing….you’re one hell of C bloogger this’s Great now i can C
gobsmack
December 24th, 2010 - 03:22
I had to “chmod” all the directories under /usr/include to 755 to allow them to be read by
the compiler:
find /usr/include -follow -type d -exec chmod 755 {} \;
Maybe because I installed everything as root and compiled as mobile?
I didn’t have to “ldid -S” in order to run the resulting hello command.
I noticed several times that being in cydia on my iPad at the same time I tried to install
something from the command line would interfere with the install. I got errors like this:
Rons-iPad:~ root# apt-get install ldid
E: Could not get lock /var/lib/dpkg/lock – open (35: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
Cheers!
Sergiu Moza
December 25th, 2010 - 21:56
…syshalt.net/…/compile-c-applications-w… 5/8
3/24/2011 December 25th, 2010 - 21:56 Compile C applications with gcc on iOS 4…
gobsmack, Cydia uses dpkg so you wont be able to use apt-get as long as the application
is opened. cydia is slow, so if you want to keep you applications updated just use apt-get
update and then apt-get upgrade in order to keep applications up to date (those who were
installed with cydia)
Celtrix
December 30th, 2010 - 22:26
Thanks for the info does this successfully implement the STD C library?
Jeremy
January 3rd, 2011 - 08:49
Thanks
Sergiu Moza
January 3rd, 2011 - 23:14
hi there,
1. your phone needs to be jailbreaked, and you can use guide both on windows, linux,
mac.
2. u need to jailbreak the iphone then install openssh from cydia.
3. read guide careful:
—- Connect iPhone to your wireless network and SSH to it (using putty or any other ssh
client).
—- Download this application (from terminal) using: wget
http://www.syshalt.net/iphone/gcc-iphone/fake-libgcc_1.0_iphoneos-arm.deb
—- Install libcc using command: dpkg –i fake-libgcc_1.0_iphoneos-arm.deb
—- “Install gcc from Cydia with command (type this command in terminal): apt-get install
iphone-gcc”
Joe
January 8th, 2011 - 18:29
ykee
January 12th, 2011 - 13:53
…syshalt.net/…/compile-c-applications-w… 6/8
3/24/2011 Compile C applications with gcc on iOS 4…
C0deH4cker
January 25th, 2011 - 22:47
@Jeremy
1) Mac is not necessary. This is just so your iPhone can compile c programs by itself.
Khalil Ounis
January 26th, 2011 - 11:17
Thank you very much for the instructions, i have just put those instructions in a bash
script, to make it easy to install for users, the guide is in this link:
http://www.89geek.com/?p=68, and thanks again author
Pete
February 15th, 2011 - 18:31
Sergiu Moza
February 15th, 2011 - 22:43
@Pete
dpkg -r fake-libgcc_1.0_iphoneos-arm.deb
Pete
February 15th, 2011 - 23:23
Thanks Sergiu, that’s what I did tried but it gives me no error messages and it does
nothing. I must have hosed something.. I’ll have to restore… oh well.
Nate
February 16th, 2011 - 07:21
Liero
February 27th, 2011 - 08:22
…syshalt.net/…/compile-c-applications-w… 7/8
3/24/2011 Compile C applications with gcc on iOS 4…
Liero
February 27th, 2011 - 08:54
You’d better add this to your article in case someone else has the same problem.
Thanks for your tutorial!
Nemo
March 17th, 2011 - 22:40
For those interested in g++: If you have access to the apple SDK you can find the headers
in the /Developers directory. You can just copy the contents of the C++ directory to
/usr/include/c++. Then also copy the libstdc++.dylib to /usr/lib, the g++ works.
Leave a comment
Name (required)
Email (required)
Website
Submit
…syshalt.net/…/compile-c-applications-w… 8/8