【问题标题】:linking openssl to visual studio 2013 LNK2019将 openssl 链接到 Visual Studio 2013 LNK2019
【发布时间】:2015-04-04 03:30:26
【问题描述】:

我正在开发 Visual Studio 2013 应用程序,因此我需要包含 openssl 库。

到目前为止我做了什么:

  • 我从这里下载了 VS2013 openssl-1.0.1l-vs2013.7z 的预编译 openssl 库:http://www.npcglib.org/~stathis/blog/precompiled-openssl/(最新稳定条目 MSVC2013)

  • 包含 openssl 的包含目录到 C/C++/General/Additional 包含目录

  • lib64/libeay32MTd.liblib64/ssleay32MTd.lib 添加到链接器/输入/附加依赖项

  • 我以这种方式调用 openssl 标头:#include <openssl\pem.h>(例如)

我在带有多线程运行时库 (/MTd) 的 64 位 Windows 机器上使用 VS 2013。每次我想构建我的项目时,它都会给我以下错误:

错误 LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_BIO_new_mem_buf" in Funktion "__catch$?decrypt@cipherEngine@@QAE?AV?$basic_string@DU?$char_traits@D@std@@ V?$allocator@D@2@@std@@PADH@Z$4".

错误 LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_RSA_private_decrypt" in Funktion "__catch$?decrypt@cipherEngine@@QAE?AV?$basic_string@DU?$char_traits@D@std@@ V?$allocator@D@2@@std@@PADH@Z$4".

错误 LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_PEM_read_bio_RSAPrivateKey" in Funktion "__catch$?decrypt@cipherEngine@@QAE?AV?$basic_string@DU?$char_traits@D@std@@ V?$allocator@D@2@@std@@PADH@Z$4".

error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: class std::basic_string,class std::allocator > __thiscall cipherEngine::rsaPrivateDecrypt(class std::basic_string,class std: :allocator >)" (?rsaPrivateDecrypt@cipherEngine@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V23@@Z)" 在 Funktion ""public: bool __thiscall cipherEngine::alterKey(class std::basic_string,class std::allocator >)" (?alterKey@cipherEngine@@QAE_NV?$basic_string@DU?$char_traits@D@std@@V?$分配器@D@2@@std@@@Z)"。

致命错误 LNK1120: 4 nicht aufgelöste Externe

谁知道“缺失的链接”?

【问题讨论】:

  • 因为非德语母语人士可能难以理解德语错误消息:这些链接器错误抱怨对BIO_new_mem_bufRSA_private_decryptPEM_read_bio_RSAPrivateKeycipherEngine::rsaPrivateDecrypt 的未定义引用。
  • 您的链接行中似乎缺少加密模块。我没有在 Windows 上做过,但如果命名方案有任何指示,库将类似于:lib64/crypto32MTd.lib

标签: c++ visual-studio-2013 openssl


【解决方案1】:

向 VS 添加外部库时,我通常会尝试包含库源并在我自己的树中构建它们。这避免了我认为您看到的问题,即预编译库的编译选项与您的主项目略有不同。不同的选项会使您无法使用该库。

如果您真的不想在项目中编译 lib,请尝试进一步调查这些符号以识别编译变体。

【讨论】:

    【解决方案2】:

    我忘了定义类,函数rsaPrivateDecrypt 属于(我感到羞耻)。第二件事是使用 32 位库而不是 64 位库。

    【讨论】:

      猜你喜欢
      • 2014-09-06
      • 1970-01-01
      • 1970-01-01
      • 2014-12-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-01
      • 1970-01-01
      相关资源
      最近更新 更多