为ios编译openssl

ios版本:5.1

os:lion 10.7.4

1)编译arm6

makedir arm6lib

./configure BSD-generic32 --prefix=/libs/openssl --openssldir=/libs/openssl

更改文件MakeFile

CC=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -arch armv7
CFLAG= -DOPENSSL_THREADS -pthread -D_THREAD_SAFE -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DTERMIOS -O3 -fomit-frame-pointer -Wall -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk

make 

make install

将arm6lib 目录复制出来

 

删除openssl-0.9.8d目录因为发现make clean并不是真的全部清除,留有很多.o文件 直接在这个在环境中编译arm7的会产生错误

 

2) 编译arm7

在新的环境中编译和arm6的类似6

 makedir arm7lib

./configure BSD-generic32 --prefix=/libs/openssl --openssldir=/libs/openssl

更改文件MakeFile

CC=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -arch armv7
CFLAG= -DOPENSSL_THREADS -pthread -D_THREAD_SAFE -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DTERMIOS -O3 -fomit-frame-pointer -Wall -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk

make 

make install

将arm7lib 目录复制出来

3)连接为universal lib

前面我们将arm6lib arm7lib复制到一个目录,进入这个目录

lipo -create ./arm6lib/lib/libcrypto.a  ./arm7lib/lib/libcrypto.a  -output ./libcrypto.a

lipo -create ./arm6lib/lib/libssl.a  ./arm7lib/lib/libssl.a  -output ./libssl.a

检验结果

lipo -info libssl.a 

结果为:

   Architectures in the fat file: libssl.a are: armv6 armv7 

表示成功

 

4)模拟器编译

与上面类似,只是修改Makefile时有点不同

CC=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc -arch i386
CFLAG= -DOPENSSL_THREADS -pthread -D_THREAD_SAFE -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DTERMIOS -O3 -fomit-frame-pointer -Wall -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值