在Qt5上去静态库:架构的未定义符号x86_64:



我在Qt5中使用了一个go构建静态库,我通过以下方式将其添加到.pro文件中:

LIBS += /Users/xxxx/Desktop/xxxxxx/framework/xxxx.a

当我编译时,它给了我这个错误:

Undefined symbols for architecture x86_64:
"_SecCertificateCopyNormalizedIssuerContent", referenced from:
_isRootCertificate in xxxx.a(000021.o)
"_SecCertificateCopyNormalizedSubjectContent", referenced from:
_isRootCertificate in xxxx.a(000021.o)
"_SecCertificateCopyShortDescription", referenced from:
_CopyPEMRoots in xxxx.a(000021.o)
"_SecItemExport", referenced from:
_CopyPEMRoots in xxxx.a(000021.o)
"_SecPolicyCopyProperties", referenced from:
_isSSLPolicy in xxxx.a(000021.o)
"_SecTrustSettingsCopyCertificates", referenced from:
_CopyPEMRoots in xxxx.a(000021.o)
"_SecTrustSettingsCopyTrustSettings", referenced from:
_sslTrustSettingsResult in xxxx.a(000021.o)
"_kSecPolicyAppleSSL", referenced from:
_isSSLPolicy in xxxx.a(000021.o)
"_kSecPolicyOid", referenced from:
_isSSLPolicy in xxxx.a(000021.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [xxxx.app/Contents/MacOS/xxxx] Error 1
09:27:27: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project xxxx (kit: Desktop Qt 5.13.1 clang 64bit)
When executing step "Make"

但是当我使用nm xxxx.a时,我确实看到了符号:

xxxx.a(000021.o):
U _CFArrayGetCount
U _CFArrayGetValueAtIndex
U _CFDataAppendBytes
U _CFDataCreateMutable
U _CFDataGetBytePtr
U _CFDataGetLength
U _CFDictionaryContainsKey
U _CFDictionaryGetValueIfPresent
U _CFEqual
U _CFNumberGetValue
U _CFRelease
U _CFStringCreateWithCString
U _CFStringGetCString
U _CFStringGetLength
U _CFStringGetMaximumSizeForEncoding
0000000000000000 T _CopyPEMRoots
U _SecCertificateCopyNormalizedIssuerContent
U _SecCertificateCopyNormalizedSubjectContent
U _SecCertificateCopyShortDescription
U _SecItemExport
U _SecPolicyCopyProperties
U _SecTrustSettingsCopyCertificates
U _SecTrustSettingsCopyTrustSettings
U ___stack_chk_fail
U ___stack_chk_guard
U ___stderrp
0000000000000890 T __cgo_0c91096c4ae5_Cfunc_CFDataGetBytePtr
00000000000008f0 T __cgo_0c91096c4ae5_Cfunc_CFDataGetLength
0000000000000950 T __cgo_0c91096c4ae5_Cfunc_CFRelease
0000000000000980 T __cgo_0c91096c4ae5_Cfunc_CopyPEMRoots
U __cgo_topofstack
U _fprintf
U _free
00000000000007e0 t _isRootCertificate
00000000000009f0 t _isSSLPolicy
U _kCFAllocatorDefault
U _kSecPolicyAppleSSL
U _kSecPolicyOid
U _malloc
0000000000000540 t _sslTrustSettingsResult
0000000000000c38 s l___const.CopyPEMRoots.domains

怎么了?如何解决这个问题?
我试图clean并运行qmake.然而,它没有用。
我还尝试重新编译静态库,不幸的是,它也不起作用。

上面提到的所有符号都在Apple的Security框架中。
查看此链接以获取更多详细信息:链接。
我通过在.pro文件中添加以下代码片段来解决它。

macx {
LIBS += -framework Security
}

全部清理,运行 qmake 并运行它。错误现在应该消失了。

相关内容

  • 没有找到相关文章

最新更新