Thread: Compiling on iPhone 3.0
-
10-19-2009, 12:21 PM #21
Yes, I also had big problems compiling C++ code. I couldn't find anyone else who posted a solution, so I ended up digging for several hours yesterday until I finally got it. I put the solution up on a blog entry at jeremyg: Building c/c++ applications using GCC/G++ on iPhone for others.
Basically you first find where the c++ headers are located, so search for iostream or some other c++ header. For me it is at /private/var/include/c++/4.0.0. Also, it seems that iostream etc. need the file bits/c++config.h, which for me is located at /private/var/include/c++/4.0.0/i686-apple-darwin9. So, what you have to do is add those directories to the standard C++ include path before building. Do that by setting the environment variable CPLUS_INCLUDE_PATH. So for me I do:
$> export CPLUS_INCLUDE_PATH=/private/var/include/c++/4.0.0:/private/var/include/c++/4.0.0/i686-apple-darwin9
Then you can build your c++ code with g++:
$> g++ test.cpp -o test
Hope it helps.
-
01-08-2010, 05:38 AM #22
Hey.
Sorry for pushing up this topic, but I've got a problem.
I've installed fake-libgcc, the GNU C Compiler and I have copied the header-files to /usr/include. But when I want to compile something, I always get this error:I'm using an iPhone 3GS with firmware 3.1.2. Sorry for my bad English.Code:ld: library not found for -lgcc_s.10.5 collect2: ld returned 1 exit status
-
01-09-2010, 07:57 PM #23
Hi haiyyu,
The fix to this problem is detailed here: How to Make iPhone apps on any OS, on the iPhone itself, for free The Big Wide Internets
I had to get a friend with a rapidshare account to download these files for me; so for other ppl who don't have rapidshare accounts as well, here are just the required files: http://dl.dropbox.com/u/207260/gcc_files.rar
Extract these files locally and then copy them into the /usr/lib folder on your iPhone, replacing the existing files.
I am NOT taking credit for this fix; I'm just letting ppl know what worked for me.
-
01-13-2010, 06:19 AM #24
does it also work for 3.1.2 ?
-
01-13-2010, 01:46 PM #25
Yes floppycode, this works for 3.1.2.
-
01-14-2010, 02:50 PM #26
Hey damagedpunk.
Thanks.
I'll try it now.
Hey.
Compiling works now.
But when I want to start the program, it instantle exits with the message "Killed". I made the binary chmod +x and tried it with mobile and root. Here is my code:Code:#include*<stdio.h> int*main()*{ ********printf("hallo*welt!"); ********return*0; }Last edited by haiyyu; 01-14-2010 at 02:51 PM. Reason: Automerged Doublepost
Sorry for my bad English - I'm from Austria.
-
01-14-2010, 09:19 PM #27
no less than on this very same page
Another thing to note, in case anyone is having problems like I did, is that you have to sign the application in order for it to run. Otherwise you will get 'Killed' written to stderr every time you try to run your app. To run it, build your program first (i.e. gcc main.c -o testApp), then do:
$> ldid -S ./testApp
-
01-15-2010, 06:33 AM #28
Hey.
Thanks, I'll instantly try it.
Hey.
It works, thx.
Last edited by haiyyu; 01-15-2010 at 06:33 AM. Reason: Automerged Doublepost
Sorry for my bad English - I'm from Austria.
-
05-26-2010, 04:58 PM #29
-
05-26-2010, 05:42 PM #30
Fake-gcc is obsolete; I didn't understand the whole situation when I made it. Don't use it; don't recommend others use it.
My SDK installer script gives good results by installing it as a sysroot in /var/sdk:
gist: 403608 - iPhone Toolchain installer script- GitHub
Copy to /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/install-sdk, chmod +x it, then run it and follow the prompts
DHowett's Theos makefile system that many projects use will autodetect this sysroot and use it automatically
Also, distributing Apple's headers and binaries violate their license.
-
05-26-2010, 06:09 PM #31
rpetrich, will that install the toolchain on the device? Will it work?
-
05-26-2010, 06:20 PM #32
Yes, it copies it from your Mac to the iPhone/iPod touch/iPad and installs it. I wouldn't intentionally post something broken.
-
05-26-2010, 06:41 PM #33
So you need to run this on a Mac? Have you tried this: http://www.ipodtouchfans.com/forums/...=206715&page=5? I haven't yet. Anyone knows if it works?
Last edited by mohitd2000; 05-26-2010 at 06:44 PM.
-
05-31-2010, 10:12 PM #34
From the looks of the script, it could be done manually with a bit of terminal work on linux, for the sake of those of us with PCs dual-booting ubuntu or the like. Not a quick or easy task, but possibly easier than hunting down someone with a mac to borrow.
-
06-01-2010, 11:25 AM #35
I might see if i can manually get all the files from my copy of the iPhoneSDK into a .deb package for cydia?
-
06-01-2010, 04:05 PM #36
That might fall under "Also, distributing Apple's headers and binaries violate their license."
However... If you got it put together, I wouldn't turn it down.
-
The Following User Says Thank You to amazingant For This Useful Post:
Lucidoor (02-19-2011)
-
08-21-2010, 08:46 PM #37iPhoneaholic
- Join Date
- Jul 2010
- Location
- NEW FLIPPIN JERSEY
- Posts
- 424
- Thanks
- 4
- Thanked 23 Times in 22 Posts
whats the command???
-
02-21-2012, 03:16 AM #38
it works!!!
I see the fack libgcc, it's just 4KB.



LinkBack URL
About LinkBacks
Reply With Quote

