静态地与openssl lib链接

时间:2016-05-30 09:53:24

标签: windows visual-c++ openssl cryptoapi

我现在在this guide之后手动构建openssl(静态库)当我尝试将我的MFC测试应用程序与libeay32.lib链接时出现以下错误:

1>Linking...
1>libeay32.lib(e_capi.obj) : error LNK2019: unresolved external symbol __imp__CertFreeCertificateContext@4 referenced in function _capi_free_key
1>libeay32.lib(e_capi.obj) : error LNK2019: unresolved external symbol __imp__CertGetCertificateContextProperty@16 referenced in function _capi_get_prov_info
1>libeay32.lib(e_capi.obj) : error LNK2019: unresolved external symbol __imp__CertOpenStore@20 referenced in function _capi_open_store
1>libeay32.lib(e_capi.obj) : error LNK2019: unresolved external symbol __imp__CertFindCertificateInStore@24 referenced in function _capi_find_cert
1>libeay32.lib(e_capi.obj) : error LNK2019: unresolved external symbol __imp__CertEnumCertificatesInStore@8 referenced in function _capi_find_cert
1>libeay32.lib(e_capi.obj) : error LNK2019: unresolved external symbol __imp__CertCloseStore@8 referenced in function _capi_find_key
1>libeay32.lib(e_capi.obj) : error LNK2019: unresolved external symbol __imp__CertDuplicateCertificateContext@4 referenced in function _capi_load_ssl_client_cert

有什么建议吗?提前谢谢。

编辑: 我使用OpenSSL 1.0.1t源代码和Visual Studio 2008命令提示符来构建32位静态库(1.0.2版本没有成功)。我的测试应用程序在动态链接时工作正常,但我希望能够与静态库链接。我正在使用OpenSSL进行EVP对称加密和解密

1 个答案:

答案 0 :(得分:17)

  

当我尝试将我的MFC测试应用程序与libeay32.lib链接时,我收到以下错误...

您需要配置enable-capieng。另请参阅OpenSSL wiki上的Compilation and InstallationHow to use CAPI engine in OpenSSL邮件列表存档。

error LNK2019: unresolved external symbol __imp__CertFreeCertificateContext@4 referenced in function _capi_free_key 
...

配置正确后,您需要链接Windows' crypt32.lib库。例如,请参阅CertFreeCertificateContext functions。在Windows上,将以下内容添加到MSVC源文件中应该足够了:

#pragma comment (lib, "crypt32");
相关问题