c++ - 为什么 OpenSSL 在 Windows 上无法正确链接

标签 c++ .net visual-studio visual-studio-2013 openssl

我正在将 OpenSSL 1.1.0d 用于使用 Visual Studio 2013 构建的托管 C++ 项目。构建调试效果很好,但构建发布会生成以下链接器错误:

error LNK2019: unresolved external symbol _SSLv23_server_method
error LNK2019: unresolved external symbol _SSLv23_client_method
error LNK2019: unresolved external symbol _CRYPTO_num_locks
error LNK2019: unresolved external symbol _CRYPTO_set_locking_callback
error LNK2019: unresolved external symbol _CRYPTO_set_dynlock_create_callback
error LNK2019: unresolved external symbol _CRYPTO_set_dynlock_lock_callback
error LNK2019: unresolved external symbol _CRYPTO_set_dynlock_destroy_callback
error LNK2019: unresolved external symbol _OPENSSL_add_all_algorithms_noconf
error LNK2019: unresolved external symbol _EVP_cleanup
error LNK2019: unresolved external symbol _SSL_load_error_strings
error LNK2019: unresolved external symbol _SSL_library_init
error LNK2019: unresolved external symbol _ERR_free_strings
error LNK2019: unresolved external symbol _CONF_modules_free
error LNK2019: unresolved external symbol _sk_num
error LNK2019: unresolved external symbol _sk_value

我尝试使用自己构建的 OpenSSL 以及 sigmoid 的预编译版本,结果是相同的。

我的假设是,虽然这些 OpenSSL 构建使用“/MD”,但仅此还不足以与我的托管 C++ 项目兼容。然而,由于管理层没有直接调用 OpenSLL,因此我的理解是使用“/MD”进行构建就足够了。另外,调试版本工作得很好。那么为什么只有第一个版本会卡住呢?

导致这些链接器错误的原因是什么?如何解决这些错误?

最佳答案

您可能使用了错误的 OpenSSL 版本。尝试 OpenSSL v1.0.2k。它所提示的符号不包含在 1.1.x 分支中。

如有必要,请记得链接 ws_lib32.lib 和 crypt32.lib。

关于c++ - 为什么 OpenSSL 在 Windows 上无法正确链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43007289/

相关文章:

c++ - 调试后 Visual Studio 拒绝暂停

android - 使用适用于 Android 的 Xamarin.Forms 在 Android 模拟器中显示 MSAL 登录页面时出现问题

c# - 等待 BackgoundWorker.DoWork() 完成

c# - 如何正确显示重叠的用户控件?

c# - 将属性名称存储在公共(public)常量字符串中是一种好习惯吗?

c++ - 如何知道在C++中抛出异常的原因

c# - 为什么调试器/运行时不能告诉我哪个对象为空?

c++ - 组织项目依赖

c++ - 如何在 SWIG 中使用 C++ 优化标志?

C++:防止在 const 函数中更改指针的值