【问题标题】:Can't build curl with ssl for iOS无法为 iOS 使用 ssl 构建 curl
【发布时间】:2013-06-20 04:24:53
【问题描述】:

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

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

【问题讨论】:

    标签: openssl libcurl configure armv7


    【解决方案1】:

    configure脚本基本上找不到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 项目,它提供了一个针对 iOS/OSX 并支持 Darwin SSL 的 libcurl 构建系统。

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

    【讨论】:

    • 感谢您为我指明正确的方向!事实证明,头文件在 /openssl/include 中,但不在 /openssl/include/openssl 中。移动这些文件解决了一个问题。我花了几个小时弄清楚出了什么问题!谢谢!附言我还添加了 --with-random=/dev/urandom 标志以摆脱:检查“/dev/urandom”...配置:错误:交叉编译时无法检查文件存在
    猜你喜欢
    • 2019-10-13
    • 1970-01-01
    • 2020-06-30
    • 2013-01-13
    • 1970-01-01
    • 2018-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多