Personal tools
ViewsInstalling toolchain for windowsFrom ModMyi - WikiFrom 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. [edit] ToolchainThe 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:
[edit] Potentially helpful hints
[edit] Windows installationAs of Oct 31 2007 Success with building a working Hello World:
[edit] Step 1 : Obtain CygwinDownload 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.
[edit] Step 2 : Get iPhone filesystem
Choose ONE of the following methods. [edit] Method 2a : WinSCP[To do: how to get the filesystem by WinSCP] Required for this method:
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).
[edit] 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 [edit] 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.) [edit] Rest of step 2Unpack 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. [edit] Step 3 : Get Mac OS X SDK files
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
Now run Cygwin Bash Shell (from Start Menu). Type the following commands at the prompt:
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. [edit] Step 4 : Obtaining the source codeIf not already, bring up the Cygwin Bash Shell. Type the following into it:
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.
[edit] Step 5 : Building LLVMFirst, we build LLVM. In the Cygwin Bash Shell, type :
[edit] Step 6 : Building odcctoolsMake a directory to hold the toolchain.
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:
To build odcctools:
(following error may happened during make command execution: "configure.ac:12: error: possibly undefined macro: AM_PROG_LEX", use following resolution link)
[edit] Step 7: Installing iPhone headersTo set the environment variable $HEAVENLY to its path:
Install the iPhone headers to the appropriate place:
Refer to the symlink section below to check to see if the symlinks were preserved. [edit] Step 8: Installing CSUNow 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.
[edit] Step 9: Building LLVM-GCCNow we can configure and make LLVM-GCC. Make sure that $LLVMOBJDIR and $HEAVENLY are set per the instructions above:
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:
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:
(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. [edit] About symlinksSymlinks 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. [edit] 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:
[edit] Manual fix for filesystem symlinksHere 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
[I'm not sure where this next part came from] Other required iPhone filesystem sym links that need to be repaired to build toolchain:
in order to fix these links, run the following commands. Otherwise you will get errors on the last step:
[edit] Automated fix for filesystem symlinksThere is a script that will allegedly fix the symlinks, located here. [Presumably, it is the same as the following:]
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)}' [edit] 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] [edit] 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]
[edit] 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] [edit] General error: '\r': command not foundThis 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 {} \; [edit] Step 6: AM_PROG_LEX errorIf you get an error concerning AM_PROG_LEX, try running "make" again. [edit] Step 7 error: MACRO errorSome have had a "MACRO error" at Step 7, and they reportedly overcame it simply by repeating the step. [edit] 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. |





