C++ 在 Visual Studio 2012 中使用 OpenSSL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17127824/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 20:56:40  来源:igfitidea点击:

using OpenSSL in Visual Studio 2012

c++visual-studio-2012opensslmd5sha

提问by rdanee

I have downloaded the latest release version of Openssl from http://www.openssl.org/source/

我已经从http://www.openssl.org/source/下载了最新版本的 Openssl

I would like to use it in Visual Studio 2012, especially getting the md5/sha-1 hash of a file, but I can not include / setup the environment with the openssl library. To be honest I got confused what to include, and where, however I have read the README-s.

我想在 Visual Studio 2012 中使用它,尤其是获取文件的 md5/sha-1 哈希,但我无法使用 openssl 库包含/设置环境。老实说,我很困惑要包含什么以及在哪里,但是我已经阅读了 README-s。

I'm getting this error.

我收到这个错误。

Error   1   error LNK2019: unresolved external symbol _MD5_Init referenced in function _main

So my question is, I have downloaded the latest release (openssl-1.0.1e.tar.gz), what should I config in VS2012 to be able to use the lib? Thanks!

所以我的问题是,我已经下载了最新版本(openssl-1.0.1e.tar.gz),我应该在 VS2012 中配置什么才能使用 lib?谢谢!

UPDATE

更新

This question helped me also in finding the solution. Boost SSL with Visual Studio 2010 and OpenSSL

这个问题也帮助我找到了解决方案。使用 Visual Studio 2010 和 OpenSSL 提升 SSL

The steps required to use the openSSL lib with VS2012:

在 VS2012 中使用 openSSL 库所需的步骤:

  • download and install a version (I have 64bit OS, however I installed 32bit openssl) from http://slproweb.com/products/Win32OpenSSL.html.
  • New project in VS, then Configuration Properties/C/C++/General/Additional Include Directories: openssl include folder (C:\OpenSSL-Win32\include)
  • Linker/General/Additional Library Directiories: C:\OpenSSL-Win32\lib
  • Linker/Input/Additional Dependencies :
  • http://slproweb.com/products/Win32OpenSSL.html下载并安装一个版本(我有 64 位操作系统,但是我安装了 32 位 openssl)。
  • VS中新建工程,然后配置属性/C/C++/General/Additional Include Directories: openssl include folder (C:\OpenSSL-Win32\include)
  • 链接器/通用/附加库目录:C:\OpenSSL-Win32\lib
  • 链接器/输入/附加依赖项:

libeay32.lib libeay32MTd.lib libeay32MT.lib libeay32MDd.lib libeay32MD.lib ssleay32.lib ssleay32MTd.lib ssleay32MT.lib ssleay32MDd.lib ssleay32MD.lib

libeay32.lib libeay32MTd.lib libeay32MT.lib libeay32MDd.lib libeay32MD.lib ssleay32.lib ssleay32MTd.lib ssleay32MT.lib ssleay32MDd.lib ssleay32MD.lib

(It was written that I need to only add that one which matches with C/C++/Code Generation/Runtime Library, but It works me this way.)

(有人写道,我只需要添加与 C/C++/代码生成/运行时库匹配的那个,但它以这种方式工作。)

  • Copy theese files into current VS folder /VC/lib
  • 将这些文件复制到当前 VS 文件夹 /VC/lib

采纳答案by Thomas

What compiler did you use to compile OpenSSL? Did you use MinGW? If so, make sure you don't strip them (or just with --strip-unneeded) otherwise import symbols will be stripped. Do the header and lib version match?

你用什么编译器来编译 OpenSSL?你用过MinGW吗?如果是这样,请确保不要剥离它们(或仅使用 --strip-unneeded),否则导入符号将被剥离。标头和 lib 版本是否匹配?

Maybe you want to try pre built ones from: http://slproweb.com/products/Win32OpenSSL.htmlthose work for sure.

也许您想从以下网址尝试预先构建的:http: //slproweb.com/products/Win32OpenSSL.html那些肯定有效。