转自:http://dingran.iteye.com/blog/1743496
废了两天的劲,还是我笨呢,总算搞定了,希望可以帮助后来者们。
1.下载OpenSSL源代码库:
http://www.openssl.org/source/
2.分别编译arm7,ram6和i386的三个架构的静态库。
arm7的命令是:
执行Config文件:
./configure BSD-generic32 --openssldir=/Users/<用户名>/openssl-1.0.1c/新建的arm7目录
增加-DEBUG_SAFESTACK,是为了可以编译出可以Debug的库,试了不好用,希望有人能指点一下。
修改Makefile:这个是示意命令,不直接使用
CC= /Applications/Xcode\ 4.4.1.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\ 4.4.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk
arm6和arm7一样,只是-arch armv7变为-arch armv6即可。
最终使用的修订后的命令如下:
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
i386的是给模拟器用的
执行Config文件:
./configure BSD-generic32 --openssldir=/Users/<用户名>/openssl-1.0.1c/新建的i386目录
修改Makefile:示意而已,先别急
CC= /Applications/Xcode\ 4.4.1.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\ 4.4.1.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk
修改后的命令是:
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
实际上我这台机子安装的xcode路径很变态,不是在用户目录下,而是跑到根目录下了,并且Xcode.app目录变成了Xcode 4.4.1.app,这些都对我造成了很大影响,变态,强烈谴责上上个机主。
OS版本的sdk路径是:
/Applications/Xcode 4.4.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk
模拟器版本的sdk路径是:
/Applications/Xcode 4.4.1.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk
需要注意的是:/Xcode 4.4.1.app/需要是这样才行:/Xcode\ 4.4.1.app/
这也是最后的疑问,能编译出2个静态库,但是有错误:
/bin/sh: /Applications/Xcode\: No such file or directory
make[2]: *** [link_app.] Error 127
make[1]: *** [openssl] Error 2
make: *** [build_apps] Error 1
看提示,可能就是这个反斜杠导致的问题!所以我想重新装xcode,直接用最新版本的。
解决办法:
先将Xcode 4.4.1.app文件夹名称修改成Xcode.app,然后路径就使用/Applications/Xcode.app/*,这样就没有空格的干扰了,注意此时的xcode不能使用了,必须在完事后修改回来。mv Xcode.app Xcode\ 4.4.1.app
make完毕后会出现如下提示:
making all in tools...
make[1]: Nothing to be done for `all'.
此时执行make install,编译出的库文件就安装到指定的目录中了。
每次编译新一种库都要先清理上次的残留,make clean,但还是会有影响,所以我每次都删除后,解压出新的重新开始。clean失败的原因也跟你mkdir的新文件夹的名字有关系,比如不能是lib*这样的,陷阱真多啊,别的名字也不行,关键是下一级目录中有lib文件夹,遇到后它也停止clean了,变态吧,呵呵。
合并3个版本的库:
lipo -create libarm7/lib/libssl.a openssl_arm6/lib/libssl.a libi386/lib/libssl.a -output libssl.a
lipo -create libarm7/lib/libcrypto.a openssl_arm6/lib/libcrypto.a libi386/lib/libcrypto.a -output libcrypto.a
查看生成的库是否正常:
lipo -info libssl.a
Architectures in the fat file: libssl.a are: armv7 armv6 i386
lipo -info libcrypto.a
Architectures in the fat file: libcrypto.a are: armv7 armv6 i386
OK,开始使用了,这回可是正确的库了,强烈鄙视openssl的团队,编译出错还能出库,库也不好用,害死我了,靠。
分享到:
相关推荐
基于iPhone15.5.sdk版本的OpenSSL库
编译ios版openssl_脚本更新.zip。更新匹配新版XCode5默认路径并新增5s的armv7s。 需要自行下载openssl源码包。 详见 http://blog.csdn.net/piao_polar/article/details/8615002
iOS编译OpenSSL静态库(使用脚本自动编译) ARCH_LIST=("armv7" "armv7s" "arm64" "i386" "x86_64") -miphoneos-version-min=6.0
ios openssl 编译批处理 需自行下载openssl 源码包,详见 http://blog.csdn.net/piao_polar/article/details/8615002
在linux系统上,用自带的交叉编译工具对openssl源码进行交叉编译(该过程可参考百度),生成对应的静态和动态库,然后将生成的库拷贝至arm设备的QT库锁存放的位置,这样的目的是当我们在设备上跑qt程序时,使用https...
ios 环境 使用curl https 不用iOS原生的网络请求 而用c语言的网络请求来下载文件,下载后保存到沙盒里面
OpenSSL 1.1.1 iOS和Android的编译脚本 需要的直接执行 ssh 命令 即可自动下载 编译 openssl
在Windows上编译安装OpenSSL-1.0.0e.tar.gz教程
linux 2.6.28内核下编译openssl,正常编译openssl-0.9.8a.tar.gz(成功).配套
本资源主要配合博文:在win7(32bit)下编译openssl完整过程,相关的软件有(均从官网下载): ActivePerl-5.14.2.1402-MSWin32-x86-295342.msi awk.exe nasm-2.10rc15-installer.exe openssl-1.0.1c.tar.gz zlib-...
linux下编译/交叉编译openssl-1.1.1g生成动态库和静态库方法: 一、编译linux版本 1. cp openssl-1.1.1g.tar.gz /opt/ 2. tar -zxvf openssl-1.1.1g.tar.gz 3. mkdir build 4. ./config --prefix=/opt/openssl-1.1.1...
OpenSSL3.0.0 msvc2019 x64和x86 静态编译
windows下编译openssl 1.1.1所需要的东西打包,包括perl、nasm、openssl源码包
CentOS7环境下编译的openssl 3.0动态库和静态库,经过测试,库可以正常使用
ios openssl(libssl.a和libcrypto.a)编译 支持 i386 armv7 armv7s arm64
vs2015编译的openssl-1.0.2h x64的静态库,里面包含头文件,dll 文件及lib文件.用来解决VS2010下可以正常用,而在vs2015下就报错,需要替换调头文件及lib文件就可以正常。
编译openssl库的方法,这些方法都是验证过了的,可以使用的
iOS下的openssl安装文件以及安装说明
适用于iPhone的OpenSSL:用于为iOS设备(iPhone,iPad,iPod Touch,AppleTV,MacCatalyst)编译OpenSSL的脚本
iOS openssl加密解密DEMO