在xcode中静态链接libcurl时出现问题

时间:2014-12-14 16:38:55

标签: c++ ios xcode libcurl

我收到以下链接器错误

  

Undefined symbols for architecture x86_64: "_SSLDisposeContext", referenced from: _darwinssl_connect_common in libcurl.a(libcurl_la-curl_darwinssl.o) _Curl_darwinssl_close in libcurl.a(libcurl_la-curl_darwinssl.o) "_SSLNewContext", referenced from: _darwinssl_connect_common in libcurl.a(libcurl_la-curl_darwinssl.o) "_SSLSetEnableCertVerify", referenced from: _darwinssl_connect_common in libcurl.a(libcurl_la-curl_darwinssl.o) "_SSLSetProtocolVersionEnabled", referenced from: _darwinssl_connect_common in libcurl.a(libcurl_la-curl_darwinssl.o) "_SecCertificateCopyLongDescription", referenced from: _darwinssl_connect_common in libcurl.a(libcurl_la-curl_darwinssl.o) _append_cert_to_array in libcurl.a(libcurl_la-curl_darwinssl.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

lipo -info说:Architectures in the fat file: libcurl.a are: i386 armv7 armv7s x86_64 arm64

security.framework 已关联

提前谢谢你 问候 d

2 个答案:

答案 0 :(得分:3)

“libcurl.a”文件中可能缺少以下功能。你自己编译libcurl了吗?如果是这样,请查找一些可能允许包含这些函数的编译选项,并重新编译。

SSLDisposeContext()
SSLNewContext()
SSLSetEnableCertVerify()
SSLSetProtocolVersionEnabled()
SecCertificateCopyLongDescription()

此外,关于Stack Overflow的这个现有问题可能会有所帮助:libcurl linker error on Xcode5 but working fine on Xcode 4.6(基本上,你的libcurl版本可能太旧,所以检查更新)

编辑:问题可能与安全框架有关,正如评论中提到的Mobile Ben。不过,相关问题可能有所帮助。

答案 1 :(得分:0)

您是否忘记添加-ObjC链接器标志??

链接器尝试仅包含所需代码的效率,有时可以排除静态库代码。使用此标志,可以正确加载库中的所有Objective-C类和类别。

enter image description here

enter image description here