在你的 iOS App中 使用 OpenSSL 库
来源:互联网 发布:51单片机蜂鸣器电路图 编辑:程序博客网 时间:2024/06/08 17:03
原文地址:http://www.x2on.de/2010/07/13/tutorial-iphone-app-with-compiled-openssl-1-0-0a-library/ ,本文有少许地方做了调整。
1、下载OpenSSL源代码库:
http://www.openssl.org/source/
当前最新版本1.0.0d。
下载后,将其中的 openssl-1.0.0x 目录解压出来放在合适的地方。
2、编译OpenSSL
openssl是一个c语言函数库,为方便在Xcode中使用,我们需要把它编译为静态库。
打开crypto/ui/ui_openssl.c进行编辑。
将
static volatile sig_atomic_t intr_signal;
修改为:
static volatile int intr_signal;
否则会出现一个编译错误。
2.1 编译 i386 库(用于iPhone模拟器)
执行以下命令:
mkdir ssllibs
将在用户主目录下建立ssllibs目录。
切换到openssl-1.0.0a安装(解压)目录,在其下建立3个子目录:
cd openssl-1.0.0a
mkdir openssl_armv6 openssl_armv7 openssl_i386
执行目录下的congfigure:
./configure BSD-generic32 --openssldir=/Users/<username>/openssl-1.0.0a/openssl_i386
编辑 makefile 文件,找到:
CC= gcc
修改为:
CC= /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc -arch i386
下一行,在CFLAG = 的后面增加
-isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk
进行编译:
make
make install
执行到make时,报错:
make[1]: /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc: No such file or directory
实际上我查了在 /应用程序/xcode/developer/...下面是有设个gcc的
解决:要加上全路径, /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc
注意:
1、在windows下下载的压缩文件不要在windows下解压,要在mac os下解,否则里面的链接文件的链接会丢失。
2、尽量在每次make前都要make clean下,不然会出现不必要的错误。
CC= /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -arch armv7
CFLAG=-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk
今天终于搞定了armv7(amv6和amv7s也是一样的道理),两个静态库,libssl.a和libcrypto.a。测试OpenSSL的一个项目是发现如果用5.1SDK编译的.a同样可适用于5.0SDK。
- 在你的 iOS App中 使用 OpenSSL 库
- 在你的 iOS App中 使用 OpenSSL 库
- 在你的 iOS App中 使用 OpenSSL 库 转发
- 在你的 iOS App中 使用 OpenSSL 库
- 在你的 iOS App中 使用 OpenSSL 库
- 在你的 iOS App中 使用 OpenSSL 库
- 在你的 iOS App中 使用 OpenSSL 库
- iOS App中 使用 OpenSSL 库
- 在 iOS 中使用 OpenSSL 库
- 在iOS中使用OpenSSL库
- 在 iOS 中使用 OpenSSL 库
- iOS 在Xcode中使用OpenSSL库
- iOS项目中使用OpenSSL库
- iOS 使用OpenSSL库
- 在asio中使用OpenSSL
- [转载] iOS 问题解决--让你的app在iPhoneX中全屏显示
- IOS中使用本地通知为你的APP添加提示用户功能
- iOS中使用本地通知为你的APP添加提示用户功能
- 手机通讯录和短信丢失怎么恢复丨手机恢复软件丨
- 静态语言 VS 动态语言
- oracle lock 05 - overview of Automatic Locks
- 通知中心(NSNotificationCenter)
- android中Button控件
- 在你的 iOS App中 使用 OpenSSL 库
- [收藏]c#与word
- Python 3 函数式编程之列表解析的坑
- 每天学习一点编程(14)(数组/字符串循环移位)
- UI 创建见View视图
- 谷歌最大的难题:移动搜索营收不断下降
- dedecms标签:channelartlist当前频道的下级栏目的内容列表
- ZOJ-1884
- block使用小结、在arc中使用block、如何防止循环引用