VS 2008 上 openssl 的链接器错误
我安装了 openssl 0.9.8l 并将包含和库路径添加到 VS 目录。 (我之前在安装 boost 库时已经这样做过)。但我继续收到链接器错误。
无论如何我可以解决同样的问题。
错误如下
Error 1 error LNK2019: unresolved external symbol _BN_free referenced in function _main RSA.obj RSA
Error 2 error LNK2019: unresolved external symbol _BN_bn2dec referenced in function _main RSA.obj RSA
Error 3 error LNK2019: unresolved external symbol _BN_num_bits referenced in function _main RSA.obj RSA
Error 4 error LNK2019: unresolved external symbol _BN_generate_prime referenced in function _main RSA.obj RSA
Error 5 error LNK2019: unresolved external symbol _BN_new referenced in function _main RSA.obj RSA
Error 6 fatal error LNK1120: 5 unresolved externals C:\Visual Studio 2008\Projects\RSA\Debug\RSA.exe RSA
I installed the openssl 0.9.8l and added the include and library paths to the VS directories.
(I have done this before when installing boost libraries). But i continue to get linker errors.
Anyway i can resolve the same.
errors are as follows
Error 1 error LNK2019: unresolved external symbol _BN_free referenced in function _main RSA.obj RSA
Error 2 error LNK2019: unresolved external symbol _BN_bn2dec referenced in function _main RSA.obj RSA
Error 3 error LNK2019: unresolved external symbol _BN_num_bits referenced in function _main RSA.obj RSA
Error 4 error LNK2019: unresolved external symbol _BN_generate_prime referenced in function _main RSA.obj RSA
Error 5 error LNK2019: unresolved external symbol _BN_new referenced in function _main RSA.obj RSA
Error 6 fatal error LNK1120: 5 unresolved externals C:\Visual Studio 2008\Projects\RSA\Debug\RSA.exe RSA
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您还需要将库名称指定为“附加依赖项”。
在项目中 |属性,需要去Linker |输入。在“附加依赖项”中,您需要提供库的名称。
更新
您想要链接 libeay32.lib 和 ssleay32.lib。
您可能有多个名为 libeayMT.lib 或 libeayMDd.lib 的版本。它们是针对不同版本的运行时库构建的,您希望选择与您构建程序的方式相匹配的版本。您也可以在 C/C++ | 的“属性”对话框中找到它。代码生成 |运行时库。
You also need to specify the library names as "additional dependencies".
In Project | Properties, you need to go to Linker | Input. In Additional Dependencies, you need to provide the names of the libraries.
Update
You want to link in libeay32.lib and ssleay32.lib.
You may have multiple versions called libeayMT.lib or libeayMDd.lib. These are built against different versions of the runtime library and you want to pick the one that matches how you are building your program. You can find this also in the Properties dialog in C/C++ | Code Generation | Runtime Library.
OpenSSL 默认为多线程 DLL (/MD)。就像Klatchko之前所说的,你应该首先将你的运行时库设置为/MD,并将相应的libeay32MD.lib和ssleay32MD.lib(它们在我的计算机上的\Microsoft Visual Studio 9.0\VC\lib中)添加到Linker |下的Additional Dependency中。输入。 (确保首先将这些 .lib 文件复制到正确的目录!)
我遇到了同样的问题,这就是我修复它的方法!
顺便说一句,我使用适用于 Windows 的 OpenSSL 的二进制版本。您可以在 OpenSSL 官方网站的相关/二进制文件下找到它。
干杯!
禅宗
OpenSSL defaults to Multithreaded DLL (/MD). Just like what Klatchko said before, you should first set your Runtime Library to /MD and add corresponding libeay32MD.lib and ssleay32MD.lib (they are in \Microsoft Visual Studio 9.0\VC\lib on my computer) to Additional Dependencies under Linker | Input. (Make sure you copy those .lib files to the right directories first!)
I had the same problem and that's how I fixed it!
BTW, I use the binary version of OpenSSL for windows. You can find it on OpenSSL offical site, under related/binaries.
Cheers!
Z.Zen