无法使用ssl为iOS构建curl

时间:2013-06-19 14:17:23

标签: openssl libcurl configure armv7

我正在尝试编译curl库以在我的Xcode项目中使用它。 我按照http://www.creativealgorithms.com/blog/content/building-libcurl-ios-42中描述的步骤进行操作,并且curl库构建得很好。但是我很难为启用ssl的armv7,armv6,i386架构编译curl库。

我已经为目标架构构建了openssl库,位于

/Users/me/Desktop/MyProject/libs/openssl/.

我正在尝试使用以下脚本配置curl库:

export CC=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2
export CFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk -I/Users/me/Desktop/MyProject/libs/openssl/include/"
export LDFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk -Wl,-syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk -L/Users/me/Desktop/MyProject/libs/openssl/lib/"
./configure --with-ssl=/Users/me/Desktop/MyProject/libs/openssl  --host=arm-apple-darwin10

执行结果如下:

checking for CRYPTO_lock in -lcrypto... yes
checking for SSL_connect in -lssl... yes
checking openssl/x509.h usability... no
checking openssl/x509.h presence... no
checking for openssl/x509.h... no
checking openssl/rsa.h usability... no
checking openssl/rsa.h presence... no
checking for openssl/rsa.h... no
checking openssl/crypto.h usability... no
checking openssl/crypto.h presence... no
checking for openssl/crypto.h... no
checking openssl/pem.h usability... no
checking openssl/pem.h presence... no
checking for openssl/pem.h... no
checking openssl/ssl.h usability... no
checking openssl/ssl.h presence... no
checking for openssl/ssl.h... no
checking openssl/err.h usability... no
checking openssl/err.h presence... no
checking for openssl/err.h... no
checking x509.h usability... no
checking x509.h presence... no
checking for x509.h... no
checking rsa.h usability... no
checking rsa.h presence... no
checking for rsa.h... no
checking crypto.h usability... no
checking crypto.h presence... no
checking for crypto.h... no
checking pem.h usability... no
checking pem.h presence... no
checking for pem.h... no
checking ssl.h usability... no
checking ssl.h presence... no
checking for ssl.h... no
checking err.h usability... no
checking err.h presence... no
checking for err.h... no
configure: error: OpenSSL libs and/or directories were not found where specified!

查看config.log文件,我看到上面列出的每个文件的以下行:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2 -c -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk -isystem /Users/me/Desktop/MyProject/libs/openssl/include/ -g0 -O2 -Wno-system-headers  -I/Users/me/Desktop/MyProject/libs/openssl/include -I/Users/me/Desktop/MyProject/libs/openssl/include/openssl conftest.c >&5
conftest.c:77:25: error: openssl/err.h: No such file or directory

你能不能给我一个线索,我做错了什么?

1 个答案:

答案 0 :(得分:3)

基本上配置脚本找不到openssl头文件。

/Users/me/Desktop/MyProject/libs/openssl/下你有什么?默认情况下你应该有这样的东西:

├── include
│   └── openssl
│       ├── ssl.h
│       ├── ...
├── lib
│   ├── libssl.1.0.0.dylib
│   ├── libssl.a
│   ├── ...

话虽如此,是否有任何理由不使用原生Darwin SSL库(a.k.a Secure Transport)?从版本7.27.0开始,libcurl现在原生支持它,这非常方便。

您一定要参考这个curl-ios-build-scripts项目,该项目为libcurl提供构建系统,该系统面向iOS / OSX并支持Darwin SSL。

如果您需要坚持使用openssl,可以参考以前用于支持它的项目的旧版本:请参阅commit 92f40bc