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