My favorites | Sign in
Project Logo
                
Search
for
Updated Sep 21, 2009 by toelooper
Labels: Phase-Deploy
Installation  
Installation of the toolchain

Building the Toolchain

The toolchain version does not necessarily need to coincide with the running firmware on your target iPhone. For example, 2.2 software can run on a 2.1 iPhone and 2.1 software can run on a 2.2.1 iPhone and so on (this is a very general statement; software relying on private frameworks or certain version-specific features may require an exact version). You may also use any new version of the SDK to build older versions of the toolchain, for instance the 2.2.1 SDK can still be used to build the 2.1 toolchain (just change TOOLCHAIN_VERSION in the script).

All that being said, the instructions below indicate how to build a toolchain specific to each recent major iPhone firmware version.

Toolchain for firmware 3.0

Before starting

We switched now to firmware 3.0. If you are interested in older firmwares see below. The firmware 3.0 support is very fresh. If you have some troubles please leave a comment or an issue.

We are busy and don't have much time to maintain the toolchain.sh script. If you think you could help please drop a note.

Checkout and get the files

First create a project directory and check out the latest copy of the toolchain builder. For Example:

mkdir -p ~/Projects/iphone/
cd ~/Projects/iphone/toolchain
svn checkout http://iphonedevonlinux.googlecode.com/svn/trunk/ ./

You will need to download the iPhone SDK 3.0 from Apple, which can be found here: http://developer.apple.com/iphone/ You can also choose to download the 3.0 or 3.0.1 firmware from Apple at this stage. If you do not, the script will download the firmware automatically (Firmare 3.0 iPhone(3G)).

You can now copy the SDK and Firmware (if you have it) to the toolchain builder's directory:

cd ~/Projects/iphone/toolchain
mkdir -p files/firmware
mv /path/to/iphone_sdk_3.0__leopard__9m2736__final.dmg files/
mv /path/to/iPhone1,2_3.0_7A341_Restore.ipsw files/firmware

Packages needed to compile the toolchain

Before you start to build the firmware you need some packages installed on your system. Building the toolchain with gcc-4.2 on my debian amd64 failed. I use gcc-4.3.

Here we provide a list of packages for Debian/Ubuntu

apt-get install \
  automake \
  bison \
  cpio \
  flex \
  g++ \
  g++-4.3 \
  g++-4.3-multilib \
  gawk \
  gcc-4.3 \
  git-core \
  gobjc-4.3 \
  gzip \
  libbz2-dev \
  libcurl4-openssl-dev \
  libssl-dev  \
  make \
  mount \
  subversion \
  sudo \
  tar \
  unzip \
  uuid \
  uuid-dev \
  wget \
  xar \
  zlib1g-dev \

If you are on 64 bit please install:

apt-get install g++-4.3-multilib gcc-4.3-multilib gobjc-4.3-multilib 

Startup and build

Now the environment is set up, you can start the script with:

chmod u+x toolchain.sh
./toolchain.sh all

After all steps, the toolchain is in ./toolchain with the binaries in ./toolchain/pre/bin and the system in ./toolchain/sys/ After a rebuild you may get patch warnings/errors. Ignore them because the build tries to patch already patched files.

With the newest version of the toolchain.sh script you can control the behaviour and the filesystem places of the toolchain file with environment vars:

  BUILD_DIR:
    Build the binaries (gcc, otool etc.) in this dir.
    Default: $TOOLCHAIN/bld

  PREFIX:
    Create the ./bin ./lib dir for the toolchain executables
    under the prefix.
    Default: $TOOLCHAIN/pre

  SRC_DIR:
    Store the sources (gcc etc.) in this dir.
    Default: $TOOLCHAIN/src

  SYS_DIR:
    Put the toolchain sys files (the iphone root system) under this dir.
    Default: $TOOLCHAIN/sys

 example:

 sudo BUILD_DIR="/tmp/bld" SRC_DIR="/tmp/src" PREFIX="/usr/local" SYS_DIR=/usr/local/iphone_sdk_3.0 ./toolchain.sh all

Toolchain for firmware 2.2 / 2.2.1

The toolchain 2.2 is outdated. This is for historical reasons.

First create a project directory and check out the latest copy of the toolchain builder. For Example:

mkdir -p ~/Projects/iphone/
cd ~/Projects/iphone/toolchain
svn checkout http://iphonedevonlinux.googlecode.com/svn/branches/2.2 ./

You will need to download the iPhone SDK 2.2.1 from Apple, which can be found here: http://developer.apple.com/iphone/ You can also choose to download the 2.2.1 firmware from Apple at this stage. If you do not, the script will download the firmware automatically.

You can now copy the SDK and Firmware (if you have it) to the toolchain builder's directory:

cd ~/Projects/iphone/toolchain
mkdir -p files/firmware
mv /path/to/iphone_sdk_2.2.1_file files/
mv /path/to/firmware2.2.1_file files/firmware

Now the environment is set up, you can start the script with:

chmod u+x toolchain.sh
./toolchain.sh all

After all steps, the toolchain is in ./toolchain with the binaries in ./toolchain/pre/bin and the system in ./toolchain/sys/

Toolchain for firmware 2.1

Support also exists for firmware 2.1. You can build it in much the same way as the instructions for 2.2 above, with the only variation being in the first command block:

mkdir -p ~/Projects/iphone/
cd ~/Projects/iphone/toolchain
svn checkout http://iphonedevonlinux.googlecode.com/svn/branches/2.1/ ./

Note: If you are supplying your own ipsw, it must be for firmware 2.1. However it is okay to use iPhone SDK 2.2, which can be downloaded from here: http://developer.apple.com/iphone/ as this still contains the required components.

Testing the Toolchain

In the subversion repository is a directory called "apps" which contains a test application you can build and deploy for the iPhone. Regardless of whether you built a 2.1, 2.2 or 3.0 toolchain, the instructions for testing are the same. You will need an iPhone connected to your local network to do this.

Navigate to the apps/HelloToolchain directory and run the following commands, noting that you must set "IP" to the address of your iPhone and change the path as appropriate:

cd ~/Projects/iphone/apps/HelloToolchain
IP=xxx.xxx.xxx.xxx PATH=../../toolchain/pre/bin/:$PATH make deploy

After running the above commands successfully, your iPhone should respring and you should see a HelloToolchain icon on the home screen. Run it and it should display "HelloToolchain" on the screen on a white background. This should indicate that the toolchain has successfully compiled an application for your iPhone. Happy coding!

Manual Steps

The instructions above recommend building the toolchain using the command:

./toolchain.sh all

This command encompasses all stages of building the toolchain. If for any reason you need to repeat a part of the process or perform it in components, you may call the script in other ways. For example, the "all" action is equivalent to running:

./toolchain.sh headers
./toolchain.sh firmware
./toolchain.sh darwin_sources
./toolchain.sh build
./toolchain.sh clean

A brief overview of the available actions and what they do, is available by running:

./toolchain.sh usage

Comment by somoro...@yahoo.de, Feb 09, 2009

Hello, how i can install the package xar. I can't find it. Please help me!

Comment by tolik.piskov, Feb 14, 2009

somoro: what is your linux distribution?

Comment by somoro...@yahoo.de, Feb 14, 2009

My linux distrubtion is debian 4 r6.

Comment by tolik.piskov, Feb 15, 2009

Have you tried 'apt-get install xar'? I use ubuntu, which is based on debian, and it has such package. Also check your /etc/apt/sources.list

Comment by somoro...@yahoo.de, Feb 17, 2009

OK in which source is the package xar???

Comment by 31337one, Feb 17, 2009

Does this work if one is using Cygwin as well?

Comment by 31337one, Feb 19, 2009

Using Kubuntu 8.10 or similar:

If you get an error compiling dmg2img saying "Make sure you have libbz2 and libssl"

You need these packages:

sudo apt-get install zlib1g-dev sudo apt-get install libssl-dev sudo apt-get install libcurl4-openssl-dev

Comment by 31337one, Feb 19, 2009

You may get much further after installing those packages.

Next you want:

sudo apt-get install gobjc sudo apt-get install g++

Comment by somoro...@yahoo.de, Feb 23, 2009

Thank you it works but where i can get code examples?

Comment by toelooper, Feb 23, 2009

I think it would be nice if we could collect some open examples here. We only provide a simple HelloToolchainApp? (you should have seen it in the folder apps of the toolchain script).

I wrote a little introduction to an example from developer.apple.com (UICatalog) here: http://iphonedevlinux.wordpress.com/2009/02/23/how-to-compile-the-uicatalog-example-from-developerapplecom/. That example helped me a lot understanding the UI-elements.

Comment by louis_hi...@yahoo.com, Mar 02, 2009

Thanks this works great! The only issue I had on Ubuntu 8.10/bash was getting the HelloToolchain? project to work. Simply exporting IP=xxx.xxx.xxx.xxx and then running make deploy didn't work for me. I had to create a variable in the Makefile called IP. Once I did that the 'scp' and 'ssh' commands in the 'deploy' target worked.

Comment by tolik.piskov, Mar 04, 2009

CoreLocation? headers are missing after install. I copied them manually from the SDK dmg.

Comment by toelooper, Mar 07, 2009

If added CoreLocation? to current trunk and branches/unstable. Thanks for your info.

Comment by matthew3walker, Mar 14, 2009

Hi :) The script has worked perfectly up until the build part! (other than a failed mv earlier: mv: cannot move Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk' to /home/matthew/Projects/iphone/toolchain/sdks/iPhoneOS2.2.1.sdk': Directory not empty , I'm not sure how important that is).

Output from ./toolchain.sh build ... Building cctools-iphone... Build progress logged to: toolchain/bld/cctools-iphone/make.log Build & install failed. Check make.log and install.log

make.log - nothing to be done for everything (I think I managed to get it to work by manually ./configure'ing and make'ing)

install.log - http://devhat.pastebin.com/f2a473227

Thanks in advance, Matt

Comment by toelooper, Mar 15, 2009

Hello matthew3walker,

could you please give us some more information? Do you have some files in /home/matthew/Projects/iphone/toolchain/sdks/iPhoneOS2.2.1.sdk ? Did it compile if you tried it manually? Could you compile HelloToolchain? (see: Testing the toolchain above)? If I interpret the install.log you pasted at pastebin.com right compiling ar failed.

Regards, toelooper

Comment by matthew3walker, Mar 19, 2009

Sorry, please ignore me. I did something stupid. I managed to get everything to compile by deleting the config.cache's which are in the repos (I think, it hasn't failed yet!). I submitted an issue :) Thanks for your wonderful tool! Matt.

Comment by keeg...@msn.com, Mar 25, 2009

Just thought i would add that this is a brilliant guide and is much simpler and easier than the other guides out there. Just a heads up, I have Ubuntu 8.10 on a HP Pavilion dv7 and i had to install git, gawk and xar. When i had done that it still didn't want to set up the environment so i installed a package called git-core which seemed to do the trick. Also i installed the packages 31337one suggested whilst i was downloading the firmware and that seemed to work also. Next i had ssh issues whereby i kept getting the message about the rsa key not being recognized. To overcome this i just deleted this file HomeFolder?/.ssh/known_hosts which allowed ssh to create a new one with the new key inside. Deployment was a bit buggy, i had to edit the makefile with the IP variable as louis_hi...@yahoo.com mentioned. So all in all this pretty much worked compiled fine and so did the UICatalog from the link above. The only small issue, no biggy, is the fact that i have to type in my password loads of times. Im not really a ssh or makefile expert but i wondered if there were any changes that i could do to this? Below ive posted the terminal output:

keegy@keegy-laptop:~/Projects/iphone/toolchain/apps/HelloToolchain?$ make deploy arm-apple-darwin9-gcc -c src/HelloToolchain?.m -o HelloToolchain?.o arm-apple-darwin9-gcc -lobjc -bind_at_load -framework Foundation -framework CoreFoundation? -framework UIKit -w -o HelloToolchain? HelloToolchain?.o root@192.168.2.246's password: sh: line 0: cd: /Applications/HelloToolchain?.app: No such file or directory not found root@192.168.2.246's password: HelloToolchain? 100% 61 0.1KB/s 00:00 icon.png 100% 1073 1.1KB/s 00:00 Info.plist 100% 746 0.7KB/s 00:00 HelloToolchain? 100% 14KB 13.6KB/s 00:00 root@192.168.2.246's password: keegy@keegy-laptop:~/Projects/iphone/toolchain/apps/HelloToolchain?$ make deploy arm-apple-darwin9-gcc -c src/HelloToolchain?.m -o HelloToolchain?.o arm-apple-darwin9-gcc -lobjc -bind_at_load -framework Foundation -framework CoreFoundation? -framework UIKit -w -o HelloToolchain? HelloToolchain?.o root@192.168.2.246's password: sh: line 0: cd: /Applications/HelloToolchain?.app: No such file or directory not found root@192.168.2.246's password: HelloToolchain? 100% 61 0.1KB/s 00:00 icon.png 100% 1073 1.1KB/s 00:00 Info.plist 100% 746 0.7KB/s 00:00 HelloToolchain? 100% 14KB 13.6KB/s 00:00 root@192.168.2.246's password: keegy@keegy-laptop:~/Projects/iphone/toolchain/apps/HelloToolchain?$

thanks, Kevin

Comment by 31337one, Mar 29, 2009

To those having issues with the IP or PATH variables. You did copy/paste the command from the guide? It is strange that it did not work for you. Anyways, glad you got it working and putting the variables into the makefile will actually make it easier in the future since you won't have to specify it every time. Good luck and I hope to see some more examples :)

Comment by josh2112, Apr 15, 2009

For me, the sample application installed itself in /Applications, but didn't show up on the springboard.

Apparently (this is according to some other webpage) because my iPhone is firmware 2.2.1, "killall SpringBoard?" is not enough - the Springboard caches application data so you must rebuild the cache.

If you have BossPrefs? installed you can do that by running /Applications/BossPrefs?.app/Respring. Surely there's some way to do it without third-party apps... anyone?

Comment by josh2112, Apr 15, 2009

Hints for Ubuntu (probably apply to other Debian-based distros also) -- run the following before running the toolchain script:

sudo apt-get install git git-core gobjc

The script will inform you that you need 'git'. There's a package called git, but the 'git' application itself is located in another package called 'git-core'. Install both.

Additionally, you need the GNU Objective-C compiler installed, package 'gobjc'. The script won't inform you of this.

Otherwise the script is great, the whole process is painless, and this is the only one of three different methods I've tried that actually completes successfully and gives me a working build environment! Many thanks to the developer!

Comment by ricosrealm, Apr 16, 2009

This is an awesome script... I did find a problem though in the firmware decryption key download. The web page link needs updating for the 2.x firmware. It's located here now:

http://www.theiphonewiki.com/wiki/index.php?title=VFDecrypt_Keys:_2.x

FYI, I updated the link in the script and it worked.

Comment by ricosrealm, Apr 16, 2009

Another helpful hint...

On 64-bit systems you must install the 32-bit gcc...this will clear up any build problems with the scripts.

# apt-get install gcc-multilib

link: http://code.google.com/p/iphone-dev/issues/detail?id=14

Comment by IvnSoft, Apr 28, 2009

Running the toolchain, it failed when mounting the decrypted image. It needed -t hfsplus added to the sudo mount line.

Comment by jason.c.simpson, Apr 28, 2009

Had to change: IPHONEWIKI_KEY_URL="http://www.theiphonewiki.com/wiki/index.php?title=VFDecrypt_Keys" to: IPHONEWIKI_KEY_URL="http://www.theiphonewiki.com/wiki/index.php?title=VFDecrypt_Keys:_2.x"

In order for the script to find my 2.x decrypt key. Should set this URL based on first number of FW_PRODUCT_VERSION instead.

Comment by fvanrenterghem, Apr 30, 2009

Built the toolchain on AMD64 (Debian), using gcc-multilib.

With firmware 2.2.1, the test application HelloToolchain? will only show up after executing the following (not part of build deploy script):

iPhone:~ root# /Applications/BossPrefs.app/Respring
Comment by 31337one, May 06, 2009
Comment by tut.ench.amok, May 22, 2009

i successfully compiled the chain and the hellotoolchain sample runs on my ipod touch. now i am trying to make an opengles app, but it cannot find the <OpenGLES/gl.h> include... are there any further steps to make this work? where is e.g. the #import <UIKit/UIFont.h> and why does it work, but no opengles? greets

Comment by joandp, Jun 23, 2009

console output: Building cctools-iphone... Build progress logged to: toolchain/bld/cctools-iphone/make.log Build & install failed. Check make.log and install.log I getting too this message can anyone tell what should I do ?

Comment by no.name.11234, Jul 05, 2009

Also modified IPHONEWIKI_KEY_URL="http://www.theiphonewiki.com/wiki/index.php?title=VFDecrypt_Keys:_2.x" in the script with success.

For the list of files to download from "darwin-tools.list", here is a list of alternative URLs that appear to be the same however do not require an Apple ID to download.

http://www.opensource.apple.com/tarballs/cctools/cctools-667.8.0.tar.gz

http://www.opensource.apple.com/tarballs/libsecurity_authorization/libsecurity_authorization-32564.tar.gz

http://www.opensource.apple.com/tarballs/libsecurity_cdsa_client/libsecurity_cdsa_client-32432.tar.gz

http://www.opensource.apple.com/tarballs/libsecurity_cdsa_utilities/libsecurity_cdsa_utilities-33506.tar.gz

http://www.opensource.apple.com/tarballs/libsecurity_cms/libsecurity_cms-32521.tar.gz

http://www.opensource.apple.com/tarballs/libsecurity_codesigning/libsecurity_codesigning-33803.tar.gz

http://www.opensource.apple.com/tarballs/libsecurity_cssm/libsecurity_cssm-32993.tar.gz

http://www.opensource.apple.com/tarballs/libsecurity_keychain/libsecurity_keychain-34101.tar.gz

http://www.opensource.apple.com/tarballs/libsecurity_mds/libsecurity_mds-32820.tar.gz

http://www.opensource.apple.com/tarballs/libsecurity_ssl/libsecurity_ssl-32463.tar.gz

http://www.opensource.apple.com/tarballs/libsecurity_utilities/libsecurity_utilities-32820.tar.gz

http://www.opensource.apple.com/tarballs/libsecurityd/libsecurityd-33470.tar.gz

http://www.opensource.apple.com/tarballs/DiskArbitration/DiskArbitration-183.tar.gz

http://www.opensource.apple.com/tarballs/IOKitUser/IOKitUser-388.2.1.tar.gz

http://www.opensource.apple.com/tarballs/IOGraphics/IOGraphics-193.2.tar.gz

http://www.opensource.apple.com/tarballs/IOHIDFamily/IOHIDFamily-258.3.tar.gz

http://www.opensource.apple.com/tarballs/IOStorageFamily/IOStorageFamily-88.tar.gz

http://www.opensource.apple.com/tarballs/IOCDStorageFamily/IOCDStorageFamily-39.tar.gz

http://www.opensource.apple.com/tarballs/IODVDStorageFamily/IODVDStorageFamily-26.tar.gz

http://www.opensource.apple.com/tarballs/WebCore/WebCore-351.9.tar.gz

http://www.opensource.apple.com/tarballs/CF/CF-476.14.tar.gz

http://www.opensource.apple.com/tarballs/configd/configd-210.tar.gz

http://www.opensource.apple.com/tarballs/xnu/xnu-1228.7.58.tar.gz

http://www.opensource.apple.com/tarballs/xnu/xnu-1228.3.13.tar.gz

http://www.opensource.apple.com/tarballs/Libc/Libc-498.tar.gz

http://www.opensource.apple.com/tarballs/launchd/launchd-258.1.tar.gz

http://www.opensource.apple.com/tarballs/DirectoryService/DirectoryService-514.23.tar.gz

http://www.opensource.apple.com/tarballs/JavaScriptCore/JavaScriptCore-466.1.tar.gz

Comment by kevin.boyle86, Jul 06, 2009

Hey,

Is OpenGLES not installed with this script. It seems to be a pre-req for using QuartzCore? which is where CoreAnimation? lives.

Does anyone have any info on how to get QuartzCore? or CoreAnimation? to work?

Kevin kboylo(a--t)hotmail.com

Comment by jason.lin03, Jul 08, 2009

hi, would you like to update this toolchain to IPHONE FW3.0? I really need it

Comment by angelbnet, Jul 25, 2009

hi, i too need toolchain for 3.0

Comment by kkrizka, Jul 28, 2009

This tutorial also works if you want to develop for FW3.0. But of course, you will only be restricted to the 2.2 API..

Comment by ackdrumm...@aol.com, Aug 16, 2009

um... it cant find the decrypter file for the 2.2.1 firmware. help?

Comment by mauro_pe...@yahoo.com, Aug 22, 2009

Worked perfectly for 2.1! I just had to change the following line in toolchain.sh:

IPHONEWIKI_KEY_URL="http://www.theiphonewiki.com/wiki/index.php?title=VFDecrypt_Keys:_2.x"

I had to append :_2.x to the URL.

Thank you very much for the hard work!

Comment by mauro_pe...@yahoo.com, Aug 22, 2009

The script doesn't install the OpenGL ES headers, as others pointed out. Just adding something like

# OpenGLES
echo "OpenGLES"
mkdir -p OpenGLES
cp -R -pf "${IPHONE_SDK_LIBS}"/OpenGLES.framework/Headers/* OpenGLES

... somewhere in the toolchain_build function should take care of it.

Comment by rootxx, Sep 13, 2009

in case you get this error: Make sure you have libbz2 and libssl available on your system

add: sudo apt-get install libbz2-dev

Comment by ninocass, Sep 28, 2009

works a treat on ubuntu using the 3.0SDK and 3.0 3GS firmware.

Are there any tools or tutorials for porting unix commandline tools to the iPhone.

i imagine i need to get ./configure to use the toolchain instead of the native ubuntu tools, any tips?

thanks

Comment by aschmickl, Oct 05, 2009

Does anyone have a direct link to the iphone 3.0 SDK.

I have tried http://developer.apple.com/iphone/ which only seems to allow access to the 3.1 SDK.

Unfortunately this does not appear to work with the current toolchain.sh script

Comment by vaslinux, Oct 14, 2009

Yep! It's worked!

Comment by gavin.pacini, Oct 17, 2009

Just wanted to say thank you! It is about time an up-to-date tool-chain was released for us non-mac users! :-) If you need any help with the 3.1.2 tool-chain please tell me as I am looking forward to it and hope you are still working on it!

Thanks again!!

Comment by frederic...@free.fr, Oct 18, 2009

Hi, I'm trying to build the toolchain for the 3.1.2 SDK with the 3.1 firmware, currently at the "Building gcc-4.2-iphone..." stage. Here are the modifications I made to toolchain.sh so far (in diff format) :

28c28
< TOOLCHAIN_VERSION="3.0"
---
> TOOLCHAIN_VERSION="3.1.2"
124c124
< IPHONE_SDK="iphone_sdk_*_final.dmg"
---
> IPHONE_SDK="iphone_sdk_*.dmg"
202c202
< 		if ! ${TOOLS_DIR}/vfdecrypt -i $1 -o $TMP_DECRYPTED -k $3 &> /dev/null; then
---
> 		if ! ${TOOLS_DIR}/vfdecrypt -i $1 -o $TMP_DECRYPTED -k B9CD10DD88AB615C1963E8AA04950B12DD64E0E5B11EA63C79A02AF6DB62334C710D21DA &> /dev/null; then
354d353
< 	if [ "${TOOLCHAIN_VERSION}" == "3.0" ] ; then
356,360d354
< 	elif [[ "`vercmp $SDK_VERSION $TOOLCHAIN_VERSION`" == "newer" ]]; then
< 		PACKAGE="iPhoneSDK`echo $TOOLCHAIN_VERSION | sed 's/\./_/g' `.pkg"
< 	else
< 		PACKAGE="iPhoneSDKHeadersAndLibs.pkg"
< 	fi
415a410,411
> FW_FILE="/home/frederic/Projects/iphone/files/firmware/iPhone2,1_3.1_7C144_Restore.ipsw"
> 
Comment by kvnkong, Oct 21, 2009
 Comment by frederic...@free.fr,  Oct 18 (2 days ago)

Hi, I'm trying to build the toolchain for the 3.1.2 SDK with the 3.1 firmware, currently at the "Building gcc-4.2-iphone..." stage. Here are the modifications I made to toolchain.sh so far (in diff format) :

28c28
< TOOLCHAIN_VERSION="3.0"
---
> TOOLCHAIN_VERSION="3.1.2"
124c124
< IPHONE_SDK="iphone_sdk_*_final.dmg"
---
> IPHONE_SDK="iphone_sdk_*.dmg"
202c202
<               if ! ${TOOLS_DIR}/vfdecrypt -i $1 -o $TMP_DECRYPTED -k $3 &> /dev/null; then
---
>               if ! ${TOOLS_DIR}/vfdecrypt -i $1 -o $TMP_DECRYPTED -k B9CD10DD88AB615C1963E8AA04950B12DD64E0E5B11EA63C79A02AF6DB62334C710D21DA &> /dev/null; then
354d353
<       if [ "${TOOLCHAIN_VERSION}" == "3.0" ] ; then
356,360d354
<       elif [[ "`vercmp $SDK_VERSION $TOOLCHAIN_VERSION`" == "newer" ]]; then
<               PACKAGE="iPhoneSDK`echo $TOOLCHAIN_VERSION | sed 's/\./_/g' `.pkg"
<       else
<               PACKAGE="iPhoneSDKHeadersAndLibs.pkg"
<       fi
415a410,411
> FW_FILE="/home/frederic/Projects/iphone/files/firmware/iPhone2,1_3.1_7C144_Restore.ipsw"
> 

I tried with the 3.12 firmware, and changed this:

if ! ${TOOLS_DIR}/vfdecrypt -i $1 -o $TMP_DECRYPTED -k a8a886d56011d2d98b190d0a498f6fcac719467047639cd601fd53a4a1d93c24e1b2ddc6 &> /dev/null; then
Comment by kvnkong, Oct 21, 2009

hi , it reports error while trying make. the error msg logged into make.log:

ld: library not found for -lc
collect2: ld returned 1 exit status
make[3]: *** [libgcc_s.dylib] error 1
....
make[2]: *** [stmp-multilib] error 2
rm gcov.pod fsf-funding.pod gfdl.pod gpl.pod cpp.pod gcc.pod
....
make[1]: *** [all-gcc] error 2
make[1]:leaving dir `/home/kong/iphone/toolchain/toolchain/bld/gcc-4.2-iphone'
make: *** [all] error 2

I am try to build the toolchain for the 3.1.2 SDK with the 3.1.2 firmware, and it happens at the "Configuring gcc-4.2-iphone..." stage. Following is my pc:

Linux kong-desktop 2.6.28-15-generic #52-Ubuntu SMP Wed Sep 9 10:49:34 UTC 2009 i686 GNU/Linux
Comment by jfanaian, Oct 21, 2009

frederic:

I believe the toolchain version should be rounded to 3.1 instead of putting in 3.1.2. I haven't tested this though.

Comment by jfanaian, Oct 21, 2009

I am experiencing the same problem as kvnkong. When compiling gcc-4.2-iphone I get the following error.

ld: library not found for -lc
collect2: ld returned 1 exit status
make[3]: *** [libgcc_s.dylib] Error 1
make[3]: Leaving directory `/home/jamal/devel/iphone/toolchain/toolchain/bld/gcc-4.2-iphone/gcc'
make[2]: *** [stmp-multilib] Error 2
make[2]: Leaving directory `/home/jamal/devel/iphone/toolchain/toolchain/bld/gcc-4.2-iphone/gcc'
make[1]: *** [all-gcc] Error 2
make[1]: Leaving directory `/home/jamal/devel/iphone/toolchain/toolchain/bld/gcc-4.2-iphone'
make: *** [all] Error 2

Here is some information about my environment:

jamal@jfhome gcc-4.2-iphone: gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.1-4ubuntu8' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu8)
Linux jfhome 2.6.31-13-generic #43-Ubuntu SMP Fri Oct 9 17:41:46 UTC 2009 x86_64 GNU/Linux

Thanks!

Comment by jfanaian, Oct 21, 2009
Comment by aktowns, Oct 26, 2009

The MediaPlayer? headers aren't copied over from the toolchain adding MediaPlayer? to the for loop on line 745 should fix :)

for framework in UIKit AddressBook CoreLocation OpenGLES MediaPlayer; do
Comment by fer662, Nov 09, 2009

I'm getting some weird behavior here. I got the HelloToolchain? application to install and run perfectly, but i cannot get any other to run normally, even not modyfing any code. (i.e HelloToolchain? renamed to HelloToolchain2?, changed in plist, changed object called in main(), etc etc).

The app compiles, links properly and appears in springboard, but it closes as soon as i open it. Something insteresting is that if i open the App over ssh on my cygwin console, and then open it on the phone, it will open properly and even toss the stdout to my cygwin console, which is something really useful. But i still don't know why the app doesn't run normally :S. Any tips with this?

Comment by lewisjspud, Nov 10, 2009

fer662, fake codesign the app.

get LDID from cydia, then in morbileterminal, cd /(exectuabledir)/, ldid -S executable

-S = capital.

Comment by fer662, Nov 10, 2009

NVM, i got it working, somehow my apps were uploading with the wrong permissions, i just added a chmod in my makefile and my apps started appearing fine on springboard and loading :). How do people usually debug this stuff? I have been using the legit SDK at work since it was released and even if xCode is really crappy and crashes all the time it helps a bit to have a debugger. Or will printf's have to suffice?

Comment by FreeLancer.c, Nov 15, 2009

Hi I just finished building the toolchain for the 3.1.2 SDK, and I deployed HelloToolchain?? :) this is my diff if anyone's interested:

28c28
< TOOLCHAIN_VERSION="3.1.2"
---
> TOOLCHAIN_VERSION="3.0"
124c124
< IPHONE_SDK="iphone_sdk*.dmg"
---
> IPHONE_SDK="iphone_sdk_*_final.dmg"
354c354
< 	if [ "${TOOLCHAIN_VERSION}" == "3.1.2" ] ; then
---
> 	if [ "${TOOLCHAIN_VERSION}" == "3.0" ] ; then
521,531c521,529
< #DECRYPTION_KEY_SYSTEM=$( wget --quiet -O - $IPHONEWIKI_KEY_URL | awk '\
< #			BEGIN { IGNORECASE = 1; }
< #			/name="3.0_.28Build_7A341.29"/               { found_3_0 = 1;   }
< #			/name="Root_Filesystem"/ && found_3_0        { found_root = 1;  }
< #			/title="'${HW_BOARD_CONFIG}'"/ && found_root { found_phone = 1; }
< #			/.*<pre>.*$/ && found_phone { 
< #				sub(/.*<pre>/,"", $0); 
< #				print toupper($0); exit; }
< #		')
< 
< 	 	DECRYPTION_KEY_SYSTEM="a8a886d56011d2d98b190d0a498f6fcac719467047639cd601fd53a4a1d93c24e1b2ddc6"
---
> 		DECRYPTION_KEY_SYSTEM=$( wget --quiet -O - $IPHONEWIKI_KEY_URL | awk '\
> 			BEGIN { IGNORECASE = 1; }
> 			/name="3.0_.28Build_7A341.29"/               { found_3_0 = 1;   }
> 			/name="Root_Filesystem"/ && found_3_0        { found_root = 1;  }
> 			/title="'${HW_BOARD_CONFIG}'"/ && found_root { found_phone = 1; }
> 			/.*<pre>.*$/ && found_phone { 
> 				sub(/.*<pre>/,"", $0); 
> 				print toupper($0); exit; }
> 		')
Comment by eddy...@charter.net, Nov 17, 2009

Freelance.c,

Which gcc version are you using? I am using 4.3 with Ubuntu 9.10 and 3.1.2 SDK and 3.1.2 FW and I still get the 'library not found for -lc' error. I've also tried gcc 4.2 and same result.

Comment by FreeLancer.c, Nov 18, 2009

eddy

gcc (Ubuntu 4.3.2-1ubuntu12) 4.3.2

But I still had to copy libc.dylib to make it work because it's a symlink to libSystem.B.dylib

cp sdks/iPhoneOS3.1.2.sdk/usr/lib/libSystem.B.dylib toolchain/bld/gcc-4.2-iphone/gcc/libc.dylib

Comment by eddy...@charter.net, Nov 20, 2009

Thanks! That did it. I also found that if I place libc.dylib in toolchain/bld/sys/usr/lib, it works too.

Comment by lerrytang, Nov 23, 2009

Thanks to all the instructions listed above, I have my toolchain successfully compiled. However, when I tried to "make" in apps/HelloWorldFirst? I got this error:

>$ make >path/to/arm-apple-darwin9-g++ -I/path/to/toolchain/toolchain/sys/usr/include -lobjc -bind_at_load -w HelloWorldFirst?.c -o HelloWorldFirst? >ld: library not found for -lobjc >collect2: ld returned 1 exit status >make: HelloWorldFirst? Error 1

I googled and learnt that is caused by library of objective c (I am a newbie to objective c), but since everybody else seems to have proceeded smoothly, I am wondering the reason of this error as well as the solution to this problem. Any suggestion is appreciated. _

Comment by lerrytang, Nov 23, 2009

sorry, I forget my system info. OS: Fedora 10 GCC: gcc version 4.3.2 20081105 (Red Hat 4.3.2-7) (GCC)

Comment by willh1234, Nov 24, 2009

lerrytang

Judging from this 'path/to/arm-apple-darwin9-g++ -I/path/to/toolchain/toolchain/sys/usr/include' it looks like you haven't changed the paths to where the sdk is located. Open up up the Makefile and change the CC variable to the location of the toolchain. For example on my setup i have copied the sdk to /usr/local/iphone so my path would be '/usr/local/iphone/pre/bin/arm-apple-darwin9-g++'. Alternatively you could add the toolchain path to the $PATH environment variable and leave the location in the Makefile as just 'arm-apple-darwin9-g++', doing this way would mean you do not have to modify the Makefile for each new project.

Comment by lerrytang, Nov 24, 2009

Thanks for the reply. I changed the path to the compiler, sorry for the ambiguity in my post. I rebuilt the environment and it magically worked correctly. Guess it was some error with library copying.

Comment by lerrytang, Nov 30, 2009

Hi all, I've successfully built "HelloToolChain?" and deployed it on my iphone 3.1.2. But it quits almost immediately, any suggestion? Thanks.

Comment by lerrytang, Nov 30, 2009

Plus, "HelloWorldFirst?" is also successfully built and can be run in MobileTerminal?, but the same problem occurs when it is deployed in /Application.

Comment by abbotdeng, Nov 30, 2009

Hi all, i have a question when i ./toolchain.sh all, i get a error that ERROR: dmg image is corrupted In order to extract 018-5301-002.dmg, I am going to mount it. This needs to be done as root. mount: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error (could this be the IDE device where you in fact use ide-scsi so that sr0 or sda or so is needed?) In some cases useful info is found in syslog - try dmesg | tail or so

Failed to mount 018-5301-002.dmg. any suggeston? Thanks!!!

Comment by willh1234, Dec 01, 2009

I recently upgraded my system to Ubuntu 9.10 and now the toolchain wont compile. The cctools fails with something to do with ld64. Seeing as my system is 32 bit i removed --enable-ld64 from the config and got rid of the lines making ld64 the default linker. Now cctools compiles but iphone-gcc complains that it can't find the linker. I don't know what to do i didn't have any of these problems when i was on 9.04.

Comment by willh1234, Dec 01, 2009

Now i fixed the problem of it not finding the linker but now im getting problems with libgcc_s.dylib.

Comment by knightrage, Yesterday (21 hours ago)

error building HelloToolchain?. it complains about objc library?

kevin@cerberus:~/Projects/iphone/toolchain/apps/HelloToolchain$ IP=10.0.1.2 PATH=../../toolchain/pre/bin:$PATH make 
arm-apple-darwin9-gcc -c   src/HelloToolchain.m -o HelloToolchain.o
arm-apple-darwin9-gcc -lobjc -bind_at_load -framework Foundation -framework CoreFoundation -framework UIKit -w -o HelloToolchain HelloToolchain.o
ld: library not found for -lobjc
collect2: ld returned 1 exit status
make: *** [HelloToolchain] Error 1

Sign in to add a comment
Hosted by Google Code