xcode 编译静态库

这里以libcurl 为例:

1.首先需要下载 libcurl http://curl.haxx.se/download.html .解压...

2.打开mac上的 terminal :切换到 解压的libcurl 的目录下...

3.编译配置:

export CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-gcc-4.2.1

export CFLAGS="-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk"
export LDFLAGS="-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk -Wl,-syslibroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk"
export CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp
./configure --disable-shared --without-ssl --without-libssh2 --without-ca-bundle --without-ldap --disable-ldap --host=arm-apple-darwin10

以上export的版本为本机安装的 xcode sdk版本 和 gcc版本....使用时 改为自己机子安装的... 路径也可能需要变...

通过cd 到以上路径 能找到内容,即可。

配置结束后 可以看到 :Protoclols: ............TELNET TFTP

4. 编译libcurl

(1) 打开Xcode选择: File->New Project->iOS->Library->Cocoa Touch Static Library

添加文件:Add->Existing Files (选择curl中 "src"文件夹),Add->Existing Files (选择curl中 "lib"文件夹)

(2)选中工程,打开“build”选项,查找Oher_c_flags 设置下面信息
-DHAVE_CONFIG_H -I/ca/dev/code/lib/curl/curl-latest/include -I/ca/dev/code/lib/curl/curl-latest/lib

注: /ca/dev/code/lib/curl/curl-latest就是刚才解压curl源代码的路径,在本机中是 -DHAVE_CONFIG_H -I/Users/rosa/curl-7.21.7/include -I/Users/rosa/curl-7.21.7/lib

5. 利用 lipo 制作通用版本 静态库

由于libcurl在device和simulator上要选择不同的版本,因此在实际使用的时候切换起来很不方便,可以在终端上使用mac os 自带的lipo工具制作为通用版本,通用版本的大小其实就是两个版本加起来的和。命令行如下:
lipo -create /b-debug/libcurl.a /a-debug/libcurl.a -output libcurl-debug.a
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值