3

我正在尝试编译 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

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

4

1 回答 1

3

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

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

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

话虽如此,您是否有任何理由不使用本机 Darwin SSL 库(又名Secure Transport)?从 7.27.0 版本开始,libcurl 现在原生支持它,这特别方便。

你绝对应该参考这个curl-ios-build-scripts项目,它为 libcurl 提供了一个构建系统,它以 iOS/OSX 为目标并支持 Darwin SSL。

如果你需要坚持使用 openssl,你可以参考这个项目以前支持它的版本:见commit 92f40bc

于 2013-06-19T20:24:53.873 回答