The ModMyTM Family of Sites:
ModMyMotoModMyiModMyGphone




 
 
Register or Connect with Facebook

Discuss AppStore Apps | Browse / Search Cydia | MMi Cydia Stats



Installing toolchain for windows

From ModMyi - Wiki

From The iPhone Dev Wiki Jump to: navigation, search [This is an attempt to consolidate that information from the toolchain Google Code site. Please add on, correct any inaccuracies, etc. Also, please remove/edit these bracketed stub comments as needed]. This is up to date as of Dec 22 2007.

Contents

Toolchain

The iPhone toolchain's website is here. The instructions below are a modified version of those present at the website, and are specific for the installation of the toolchain on Microsoft Windows using the Cygwin software. Status:

  • Windows Vista : Builds successfully
  • Windows XP : Builds successfully
  • Windows Server 2003 : Builds successfully

Potentially helpful hints

  • To paste text into the Cygwin shell:
  • First, with the shell running, right click on the window's title bar and select Properties. Make sure that QuickEdit Mode is enabled.
  • Whenever you need to paste text, right click on the title bar, go to the Edit menu, and select Paste.
  • If you are typing the commands below out manually, note the difference between the ` and the ' keys. The former is located below the ESC button, sharing the same key as the tilde.
  • For those who are used to an IDE, don't be intimidated by the onslaught of text you see during the build. The building process will essentially vomit on the screen, mostly commands and warnings. If you get an error, it will tell you in the last few lines before cutting back to the prompt. Scroll up to find the original error...the later errors may stem from the original one.
  • If the building of a component repeatedly fails, you may want to clean up and start over. To clean up (in certain cases), type:
  • $ make clean


Windows installation

As of Oct 31 2007 Success with building a working Hello World:

  • Windows Vista : confirmed
  • Windows XP  : built successfully and tested
  • Windows Server 2003  : built successfully and tested

Step 1 : Obtain Cygwin

Download Cygwin (setup.exe) from the Cygwin website: cygwin.com. Run setup.exe on your computer, making sure it's not blocked by your personal firewall. You should install Cygwin in C:\cygwin. Do not install it in your Program Files folder, or any other folder that contains spaces in its name (or is heavily protected). Cygwin's setup.exe will display a list of software available for download. The following list comprises things you should install. Some of them are mandatory for the installation, and some are useful in related circumstances.

  • autoconf2.1, autoconf2.5 (automatic script builder)
  • automake1.9, automake1.8, etc.
  • binutils
  • bison
  • cpio
  • ccrypt
  • curl
  • dejagnu
  • doxygen
  • flex
  • gcc-core
  • gcc-g++
  • gcc-objc
  • gdb
  • gmp
  • libtool
  • make
  • mpfr
  • ocaml
  • openssh
  • openssl
  • openssl-devel
  • patch
  • patchutils
  • subversion
  • zip

Step 2 : Get iPhone filesystem

  • Get a copy of the iPhone root filesystem. This is usually obtained by decrypting and extracting the iPhone restore software using these tools, but there are many other methods to obtain this, including simply using scp to download all the files from the iPhone over Wi-Fi.

Choose ONE of the following methods.

Method 2a : WinSCP

[To do: how to get the filesystem by WinSCP] Required for this method:

  • iPhone [not known if an iPod touch will work]
  • OpenSSH on your iPhone (obtained via Installer)
  • WinSCP on your Windows computer (obtained by free Internet download)

Simply run WinSCP, log in to your iPhone, and copy the items in the iPhone's main directory onto your PC. (This method probably doesn't conserve symlinks, but more feedback is needed to confirm this.) (Making a TAR before copying may be the best way...see the troubleshooting section below).

  • Update: using WinSCP to copy the files directly fails for all items in the /dev path, as well as a number of other socket files, etc. WinSCP also follows symlinks as though they are actual files/directories, so the symlinks will be replaced by actual copies of the file, making the total size more than double what it actually should be.) Make a tar of the entire filesystem first and copy that across using WinSCP. Then untar it using the cygwin command line. (I just learned this the hard way today! [11/12/2007])

Method 2b : Decrypting dmg

[To do: method 2b instructions] This method involves running a custom vfdecrypt program on the firmware saved by iTunes. Although it is easier than it sounds, most of the Windows programs that extract dmgs (see step 3) don't work on these particular dmgs. Therefore, it may be necessary to use a Mac for this approach. UPDATE: I performed this method on Windows using the 1.1.1 image and help from this site. iphone.fiveforty.net

Method 2c : Using SCP via Cygwin

[To do: method 2c instructions] One strategy here may be to SSH onto the iPhone and TAR the files needed. TARs preserve symlinks. After tarring, the tar can be copied onto the PC and extracted. (See the troubleshooting section for more on this.)

Rest of step 2

Unpack the root filesystem into C:\cygwin\usr\local\share\iphone-filesystem. Check the symlink section below to see if the symlinks were preserved. Certain symlinks are vital for a successful build, and many methods of transferring lose the symlink information.

Step 3 : Get Mac OS X SDK files

  • Download the Xcode DMG from Apple's Developer Tools download page. (It may be called 'Xcode 2.5' or something similar.) It is free, but you will need to register with them. It is also huge (~924 MB). (Although it's probably not needed after this step, you might want to hold onto the file somewhere, just in case you do need it again.) Make sure you get the Xcode 2.5 dmg (not 3.0). You can get it directly from here
  • Extract the Packages/MacOSX10.4.Universal.pkg directory from the Xcode DMG and place it somewhere on your computer (temporary). One program that is known to work is PowerISO, although it isn't free. Someone has said that hfsexplorer works, and it's open-source; it has been reported that errors might occur when using this program. The trial version of TransMac also works to extract this image.
  • I had success using hfsexplorer to extract the .dmg under Windows XP Prof SP2. Be certain you open the file as a UDIF, and navigate all the way into the archive to find the Archive.pax.gz. Right click on the file, extract the resource fork, then hit the extract button above to extract the file. Did the trick for me. 18 Dec 2007

Newer HFSExplorer allow only to extract .pkg file into your home folder. In such case use 7-Zip to open .pkg file. "Payload" will be similar name to "Archive.pax.gz" referenced to in next step. 06 Jul 2009

  • Go into the MacOSX10.4.Universal.pkg directory you just extracted and move the Archive.pax.gz file into the C:\cygwin directory.

Now run Cygwin Bash Shell (from Start Menu). Type the following commands at the prompt:

  • $ cd /
  • $ gunzip -c Archive.pax.gz | cpio -i

You may not get much feedback in the shell during the extraction process, but you can watch the files role out via My Computer (check C:\cygwin\Developer\ directory). This may extract it to C:\cygwin\SDKs. If so, the easiest solution would be to create a C:\cygwin\Developer directory and move the SDKs directory into that.

Before moving on, consult the symlink section below in order to confirm that the symlinks were preserved.

Step 4 : Obtaining the source code

If not already, bring up the Cygwin Bash Shell. Type the following into it:

  • $ cd /home

Check out a copy of LLVM SVN, and build a release build (as opposed to a debug one). Currently, due to Issue 70 [on the website], we are limited to revision 42498.

Check out a copy of the iphone-dev SVN repository.

Step 5 : Building LLVM

First, we build LLVM. In the Cygwin Bash Shell, type :

  • $ cd /home/llvm-svn
  • $ ./configure --enable-optimized
  • $ make ENABLE_OPTIMIZED=1
  • $ make install
  • $ LLVMOBJDIR=`pwd`
  • $ cd /home

Step 6 : Building odcctools

Make a directory to hold the toolchain.

  • $ mkdir /usr/local/arm-apple-darwin
  • $ mkdir -p /home/iphone-dev/build/odcctools

Obtain the patch that victzh made from the project's issue board on Google Code. You can try the following link: victzh's patch Place the patch in the C:\cygwin\home\iphone-dev\odcctools directory. Now back to the cygwin shell: To apply the patch:

  • $ cd /home/iphone-dev/odcctools
  • $ patch -p0 <odcctools_cygwin.patch
  • $ mv include/foreign/machine include/foreign/_machine
  • $ cd ../build/odcctools

To build odcctools:

  • $ ../../odcctools/configure --target=arm-apple-darwin --disable-ld64
  • $ make

(following error may happened during make command execution: "configure.ac:12: error: possibly undefined macro: AM_PROG_LEX", use following resolution link)

  • $ make install

Step 7: Installing iPhone headers

To set the environment variable $HEAVENLY to its path:

  • $ HEAVENLY=/usr/local/share/iphone-filesystem

Install the iPhone headers to the appropriate place:

  • $ cd /home/iphone-dev/include
  • $ ./configure --with-macosx-sdk=/Developer/SDKs/MacOSX10.4u.sdk
  • $ bash install-headers.sh

Refer to the symlink section below to check to see if the symlinks were preserved.

Step 8: Installing CSU

Now it's time to install csu, which includes crt1.o, dylib1.o, and bundle1.o. Don't rebuild them from source, as this requires a working cross-GCC, which you don't have yet (and the build-from-source process for csu is broken right now anyway). Binaries are provided for this reason.

  • $ mkdir -p /home/iphone-dev/build/csu
  • $ cd /home/iphone-dev/build/csu
  • $ ../../csu/configure --host=arm-apple-darwin
  • $ make install

Step 9: Building LLVM-GCC

Now we can configure and make LLVM-GCC. Make sure that $LLVMOBJDIR and $HEAVENLY are set per the instructions above:

  • $ $LLVMOBJDIR

It should respond: bash: /home/llvm-svn: is a directory. If it doesn't, you should repeat the pertinent part of Step 5. Now type:

  • $ $HEAVENLY

It should respond: bash: /usr/local/share/iphone-filesystem: is a directory. If it doesn't, you should repeat the pertinent part of Step 7. Now onto building:

  • $ mkdir -p /home/iphone-dev/build/llvm-gcc-4.0-iphone
  • $ cd /home/iphone-dev/build/llvm-gcc-4.0-iphone
  • $ ../../llvm-gcc-4.0-iphone/configure --enable-llvm=`llvm-config --obj-root` \
  • > --enable-languages=c,c++,objc,obj-c++ --target=arm-apple-darwin --enable-sjlj-exceptions \
  • > --with-heavenly=$HEAVENLY --with-as=/usr/local/bin/arm-apple-darwin-as \
  • > --with-ld=/usr/local/bin/arm-apple-darwin-ld
  • $ make LLVM_VERSION_INFO=2.0-svn-iphone-dev-0.3-svn
  • $ make install

(If you are unable to complete this step, again, check the symlinks from previous steps. See the symlink section below. Also see the troubleshooting section.) THAT'S ALL. [edit] What's next? Try to build the Hello World program.

About symlinks

Symlinks are UNIX/LINUX/MacOS/etc equivalents of Windows shortcuts, and when you view them in the Windows Explorer (aka My Computer), they show up as shortcuts. There are a few places where symlinks may not make the journey from Mac/iPhone to Windows, and these (some at least) will have to be replaced manually. The command for creating symlinks is (in the directory that you wish the newly created link to appear): $ ln -s WHAT_THE_LINK_POINTS_TO DESIRED_NAME_OF_LINK To check and see if symlinks made the transition to Windows, go to each of the following directories using My Computer.

Checking symlinks for iPhone filesystem (after Step 2)

Go to C:\cygwin\usr\local\share\iphone-filesystem You should see the the following symlinks in the filesystem root:

  • ./etc -> private/etc
  • ./Library/Logs -> ../private/var/logs
  • ./Library/preferences -> ../private/var/preferences
  • ./tmp -> private/var/tmp
  • ./var -> private/var

Manual fix for filesystem symlinks

Here is how to fix symlinks manually. It involves first removing the defective symlink, and then relinking the files with the 'ln' command. Type these commands in Cygwin

  • $ cd /usr/local/share/iphone-filesystem
  • $ rm var
  • $ ln -s private/var var
  • $ rm tmp
  • $ ln -s private/var/tmp tmp
  • $ rm etc
  • $ ln -s private/etc etc
  • $ rm Library/Logs
  • $ ln -s private/var/logs Library/Logs
  • $ rm Library/preferences
  • $ ln -s private/var/preferences Library/preferences

[I'm not sure where this next part came from] Other required iPhone filesystem sym links that need to be repaired to build toolchain:

  • /usr/lib/libc.dylib -> libSystem.B.dylib
  • /usr/lib/libSystem.dylib -> libSystem.B.dylib
  • /usr/lib/libm.dylib -> libSystem.B.dylib

in order to fix these links, run the following commands. Otherwise you will get errors on the last step:

  • $ pushd usr/lib
  • $ rm libc.dylib libSystem.dylib libm.dylib
  • $ ln -s libSystem.B.dylib libc.dylib
  • $ ln -s libSystem.B.dylib libSystem.dylib
  • $ ln -s libSystem.B.dylib libm.dylib
  • $ popd

Automated fix for filesystem symlinks

There is a script that will allegedly fix the symlinks, located here. [Presumably, it is the same as the following:]

  • $ cd /usr/local/share/iphone-filesystem

and run $ find -size -200c -type f | gawk '{p = ""; s = split($0, sp, "/"); for (i = 1; i < s; i++) p = p (p?"/":"") sp[i]; b = sp[s]; getline a < $0; if (match(a, /^[a-zA-Z0-9_\-\.]*$/)) if(system("if [ -e " p "/" a " ]; then exit 66; fi")==66) system("cd " p "; rm " b "; ln -s " a " " b)}'

Checking symlinks for MacOSX SDK (after Step 3)

Go to C:\cygwin\Developer\SDKs\MacOSX10.4u.sdk\usr\lib. You should see a number of files ending in .dylib. A lot of these should be shortcuts. [TODO : I'm not sure of the necessity of these symlinks]

Checking symlinks in arm-apple-darwin (after Step 7)

Go to C:\cygwin\usr\local\arm-apple-darwin\include There should be a number of symlinks in this directory, including stdint.h (which should point to gcc/darwin/default/stdint.h). These are created in the iPhone headers step. If you rerun this step, you'll find that it won't created symlinks if there is already a file there. [Perhaps the solution when you reinstall is to completely remove the /usr/local/arm-apple-darwin directory?] A list [partial?] of files that should be symlinks pointing to other things [not specified here]

  • /usr/local/arm-apple-darwin/include/ncurses.h
  • /usr/local/arm-apple-darwin/include/python2.3
  • /usr/local/arm-apple-darwin/include/stdint.h
  • /usr/local/arm-apple-darwin/include/tcl.h
  • /usr/local/arm-apple-darwin/include/tclDecls.h
  • /usr/local/arm-apple-darwin/include/tclPlatDecls.h
  • /usr/local/arm-apple-darwin/include/tk.h
  • /usr/local/arm-apple-darwin/include/tkDecls.h
  • /usr/local/arm-apple-darwin/include/tkIntXlibDecls.h
  • /usr/local/arm-apple-darwin/include/tkMacOSX.h
  • /usr/local/arm-apple-darwin/include/tkPlatDecls.h
  • /usr/local/arm-apple-darwin/include/X11
  • /usr/local/arm-apple-darwin/include/arpa/nameser.h
  • /usr/local/arm-apple-darwin/include/arpa/nameser8_compat.h
  • /usr/local/arm-apple-darwin/include/readline/history.h
  • /usr/local/arm-apple-darwin/include/gcc/darwin/default
  • /usr/local/arm-apple-darwin/include/gcc/darwin/3.3-fast
  • /usr/local/arm-apple-darwin/include/gcc/darwin/4.0/c++
  • [ IOKit/scsi-commands]

Troubleshooting/Solutions

[Solutions go here, questions go on talk page. If you came across an error message, and you solved it, and your toolchain now is functional, please post the error message, problem, and solution here.] [Note: your error was likely a bad symlink one]

General error: '\r': command not found

This generally means that one or more of the text files have been edited in the style of MS-DOS instead of the Unix. In MS-DOS formatted text files, each line ends with "\r\n" whereas in Unix formatted text files, they end simply with a "\n" (aka newline). If you edit any of the files, it's best not to use Microsoft products, as they tend to save in the MS-DOS style. The extraneous "\r"s are invisible in many text editors, but will become visible as '^M' if editing in Cygwin via the "nano --noconvert myfilename" command. Solution: re-edit any files you changed with a different text editor, or start over. To unix-fy the files, run this command in directory: find . -type f -exec dos2unix {} \;

Step 6: AM_PROG_LEX error

If you get an error concerning AM_PROG_LEX, try running "make" again.

Step 7 error: MACRO error

Some have had a "MACRO error" at Step 7, and they reportedly overcame it simply by repeating the step.

Step 9 error: Link tests are not allowed...

If after executing (in step 9) $ make LLVM_VERSION_INFO=2.0-svn-iphone-dev-0.3-svn you get an error like: checking for sin in -lm... configure: error: Link tests are not allowed after GCC_NO_EXECUTABLES it means that your symbolic links in C:\cygwin\usr\local\arm-apple-darwin\include got lost. The best way to fix this is to SSH into your iPhone and go to the directory: /usr/lib and enter the command: tar -cvf lib.tar ./lib Then SCP the lib.tar file on your iPhone to your PC and put it into the directory C:\cygwin\usr\local\share\iphone-filesystem\usr and untar the file on your PC with the command: tar -xvf lib.tar This will maintain all of the symbolic links in the lib directory and the above error should disappear. You can now delete both of the lib.tar files on your PC and your iPhone. [TODO : more explicit instructions for this]

If the error you get is like this one:

/usr/local/bin/arm-apple-darwin-ld: /usr/local/share/iphone-filesystem/usr/lib/libc.dylib
truncated or malformed object (mach header extends past the end of the file)
collect2: ld returned 1 exit status
make[2]: *** [libgcc_s.dylib] Error 1
make[2]: Leaving directory `/home/iphone-dev/build/llvm-gcc-4.0-iphone/gcc'
make[1]: *** [stmp-multilib] Error 2
make[1]: Leaving directory `/home/iphone-dev/build/llvm-gcc-4.0-iphone/gcc'
make: *** [all-gcc] Error 2

probably you forgot to fix the $HEAVENLY/usr/lib symlinks.


Go to Top
ModMyI

All times are GMT -6. The time now is 05:23 AM. Powered by vBulletin® Version 3.8.4
If you need Dedicated Server Hosting, you should check out SingleHop. | Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Powered by vbWiki Pro 1.3 RC4. Copyright ©2006-2007, NuHit, LLC
Copyright © 2007-09 by ModMy, LLC. All rights reserved.

iPhone News / iPhone Forums / Apple News / Apple Forums / RSS / Contact Us / / Top