windows 如何在 Visual Studio 中使用 OpenSSL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11383942/
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
How to use OpenSSL with Visual Studio
提问by joker
I am trying to port my console application written in C
to Visual Studio 2010. On Linux/Mac, the application runs perfectly, including OpenSSL
support.
我正在尝试将我编写的控制台应用程序移植C
到 Visual Studio 2010。在 Linux/Mac 上,该应用程序运行完美,包括OpenSSL
支持。
Can anyone provide help using/linking the OpenSSL
libs in a Visual Studio project?
任何人都可以提供使用/链接OpenSSL
Visual Studio 项目中的库的帮助吗?
Thanks!
谢谢!
回答by joker
I know it's old! I faced the problem myself and here's the solution.
我知道它老了!我自己遇到了这个问题,这是解决方案。
First of all, you should install (normal ordinary installation) openssl. (It's from here).
首先,你应该安装(正常普通安装)openssl。(它来自这里)。
Now, after you create a project, I quote:
现在,在你创建一个项目之后,我引用:
Make sure the following settings are setup in the project property pages:
[C/C++ -> General -> Additional Include Directories] value: OpenSSL's include directory in your machine (e.g C:\openssl\include)
[Linker -> General -> Additional Library Directories] value: OpenSSL's lib directory in your machine (e.g C:\openssl\lib)
[Linker -> Input -> Additional Dependencies] value: libeay32.lib
确保在项目属性页面中设置了以下设置:
[C/C++ -> General -> Additional Include Directories] 值:OpenSSL 在您机器中的包含目录(例如 C:\openssl\include)
[Linker -> General -> Additional Library Directories] 值:OpenSSL 在您机器中的 lib 目录(例如 C:\openssl\lib)
[Linker -> Input -> Additional Dependencies] 值:libeay32.lib
来源。
回答by Nagaraj Gaonkar
Add OpenSSL-related header files, and below headers:
添加 OpenSSL 相关的头文件,以及以下头文件:
#include <winsock2.h>
#include <windows.h>
Open below Link & download pre-compiled files.
打开以下链接并下载预编译文件。
http://www.npcglib.org/~stathis/blog/precompiled-openssl/
http://www.npcglib.org/~stathis/blog/precompiled-openssl/
extract and keep folder in C drive use readme_precompile.txt for instructions.
解压并将文件夹保存在 C 驱动器中,使用 readme_precompile.txt 获取说明。
Open Visual C++ project and followup procedure given in below to include and Linker options.
打开 Visual C++ 项目和下面给出的后续过程以包含和链接器选项。
Make sure the following settings are setup in the project property pages:
确保在项目属性页面中设置了以下设置:
- [C/C++ -> General -> Additional Include Directories]
- OpenSSL's include directory in your machine (e.g C:\openssl\include) or (e.g C:\openssl\include64)
- [Linker -> General -> Additional Library Directories]
- OpenSSL's lib directory in your machine (e.g C:\openssl\lib) or (e.g C:\openssl\lib64)
- [Linker -> Input -> Additional Dependencies]
ws2_32.lib
libsslMT.lib
Crypt32.lib
libcryptoMT.lib
- [C/C++ -> 常规 -> 附加包含目录]
- OpenSSL 在您机器中的包含目录(例如 C:\openssl\include)或(例如 C:\openssl\include64)
- [链接器 -> 常规 -> 附加库目录]
- 您机器中的 OpenSSL 的 lib 目录(例如 C:\openssl\lib)或(例如 C:\openssl\lib64)
- [链接器 -> 输入 -> 附加依赖项]
ws2_32.lib
libsslMT.lib
Crypt32.lib
libcryptoMT.lib
回答by Nitesh
Here are some resources: Compiling and installing OpenSSL for Windows, as well as Using OpenSSL for Cryptography (Blowfish, DES, RC2, RC4)
以下是一些资源:为 Windows 编译和安装 OpenSSL,以及使用 OpenSSL 进行加密(Blowfish、DES、RC2、RC4)
I have tried them myself yet I am still getting errors. OpenSSL and Visual Studio are not my forte, but maybe you can figure it out.
我自己尝试过,但仍然出现错误。OpenSSL 和 Visual Studio 不是我的强项,但也许您可以弄清楚。
回答by Nitesh
Well, this is more than a year old, but I couldn't find the answer so I muscled my way through. I got openssl-1.0.1e to compile using VS 11 as such:
嗯,这已经一年多了,但我找不到答案,所以我硬着头皮过去了。我让 openssl-1.0.1e 使用 VS 11 进行编译,如下所示:
I tried using the PERL that comes with git, didn't work, had to install ActivePerl
我试过用git自带的PERL,没用,只好安装ActivePerl
Taken from the linkprovided by Nitesh:
摘自Nitesh 提供的链接:
perl Configure VC-WIN64A no-asm
Followed by:
其次是:
ms\do_win64a
Per this post, I edited ms\ntdll.mak and changed CC to:
根据这篇文章,我编辑了 ms\ntdll.mak 并将 CC 更改为:
CC="c:\Program Files (x86)\Microsoft visual Studio 11.0\VC\bin\amd64\cl.exe"
Then finally:
然后最后:
nmake -f ms\ntdll.mak
I didn't bother installing and just added the directory openssl-1.0.1e\out32dll to Configuration Properties -> Linker -> Additional Library Directories and openssl-1.0.1e\inc32 to Configuration Properties -> C/C++ -> C/C++ -> General -> Additional Include Directories, copied libeay32.dll to somewhere in my path, and called it good. Seems to be working.
我没有费心安装,只是将目录 openssl-1.0.1e\out32dll 添加到 Configuration Properties -> Linker -> Additional Library Directories 和 openssl-1.0.1e\inc32 到 Configuration Properties -> C/C++ -> C/C++ -> General -> Additional Include Directories,将 libeay32.dll 复制到我路径中的某个位置,并称其为 good。似乎正在工作。