在ubuntu7.10 Linux下尝试了一下,几经周折,终于完成成功,将helloworld编译通过了,编译速度非常快。为了让大家少走弯路,现在说一下安装过程,原文见
http://code.google.com/p/iphone-dev/wiki/Building。
1.安装工具链
要顺利通过工具链的编译,在ubuntu7.10桌面版本需要首先安装以下工具,否则编译会出错:
(1)安装必要组件,ubuntu7.10默认没有安装这些工具。
bison
flex
g++
autogen
patch
可用此命令安装:sudo apt-get install 你要安装的程序名
如:sudo apt-get install bison
(2)下载
Archive.pax.gz,此为macos10的开发包。解压后连带目录结构复制至/(根目录)下,检查路径是否为: /Developer/SDKs/MacOSX10.4u.sdk/
(3)从你的iphone中取得整个解压后的固件。复制至
/usr/local/share/iphone-filesystem下。
以上两步的文件如何得到请看置顶贴。
依次在终端中输入$符号后的(最好是复制,以免输错)以下命令开始编译(不要输入$符号,遇"\"结尾的行需要将一下行一起复制执行):
取得LLVM
SVN源代码。
$ cd ~
$ svn co
http://llvm.org/svn/llvm-project/llvm/trunk llvm-svn -r 42498
$ pushd llvm-svn
$ ./configure --enable-optimized
$ make ENABLE_OPTIMIZED=1
$ sudo make install
$ LLVMOBJDIR=`pwd`
$ popd
- 创建工具链目录.$ sudo mkdir /usr/local/arm-apple-darwin
- 编译odcctools.$ mkdir -p build/odcctools
$ pushd build/odcctools
$ ../../odcctools/configure --target=arm-apple-darwin --disable-ld64
$ make
$ sudo make install
$ popd
- 确保你已经取得了iPhone的根目录系统文件,并已经复制到了
/usr/local/share/iphone-filesystem,执行以下命令。
$ HEAVENLY=/usr/local/share/iphone-filesystem
- 安装头文件,如果你没有安装patch包,这一步会导致编程helloworld出错,请确保之前已经安装了patch组件。$ pushd include
$ ./configure --with-macosx-sdk=/Developer/SDKs/MacOSX10.4u.sdk
$ sudo bash install-headers.sh
$ popd
- 安装 csu$ mkdir -p build/csu
$ pushd build/csu
$ ../../csu/configure --host=arm-apple-darwin
$ sudo make install
$ popd
- 注意,有粘连符“\”的行要一起复制后执行$ mv llvm-gcc-4.0-iphone/configure llvm-gcc-4.0-iphone/configure.old
$ sed 's/^FLAGS_FOR_TARGET=$/FLAGS_FOR_TARGET=${FLAGS_FOR_TARGET-}/g' \
llvm-gcc-4.0-iphone/configure.old > llvm-gcc-4.0-iphone/configure
$ export FLAGS_FOR_TARGET="-mmacosx-version-min=10.1"
$ sudo ln -s /usr/local/arm-apple-darwin/lib/crt1.o \
/usr/local/arm-apple-darwin/lib/crt1.10.5.o
- 确保已经根据上几步操作设置了$LLVMOBJDIR 和 $HEAVENLY 变量,继续以下命令$ mkdir -p build/llvm-gcc-4.0-iphone
$ pushd 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
$ sudo make install
$ popd
$ popd
如何没有出错信息,那么恭喜你,你已经安装了iPhone的工具链,可以编译程序了,试着编译helloworld看能不能通过。
helloworld程序, 我压后进入目录,执行make即可。
[
本帖最后由 randomdot 于 2008-1-20 13:21 编辑 ]