如何在Visual Studio中使用OpenSSL ?

时间:2022-06-27 04:54:56

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?

任何人都可以在Visual Studio项目中使用/链接OpenSSL libs吗?

Thanks!

谢谢!

4 个解决方案

#1


24  

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)

[C/ c++ ->通用->附加包括目录]值:OpenSSL在您的机器中包含目录(e)。g C:\ openssl \包括)

[Linker -> General -> Additional Library Directories] value: OpenSSL’s lib directory in your machine (e.g C:\openssl\lib)

[Linker ->通用->附加库目录]value:在你的机器上的OpenSSL的lib目录(e。g C:\ openssl \ lib)

[Linker -> Input -> Additional Dependencies] value: libeay32.lib

[Linker ->输入->附加依赖项]值:libeay32.lib。

Source.

源。

#2


3  

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不是我的强项,但也许你可以解决它。

#3


3  

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 link provided 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到配置属性-> Linker ->额外的库目录和openssl-1.0.1e\inc32的配置属性-> C/ c++ -> C/ c++ ->通用->附加包括目录,复制libeay32。dll在我的路径中,并称之为好。似乎工作。

#4


2  

Add openssl related headerfiles and below headers.

添加与openssl相关的头文件和下面的标题。

#include<windows.h>
#include<winsock2.h>

Open below Link & download pre-compiled files.

打开下面的链接和下载预编译文件。

http://www.npcglib.org/~stathis/blog/precompiled-openssl/

http://www.npcglib.org/ ~言/博客/ precompiled-openssl /

extarct and keep folder in C drive use readme_precompile.txt for instructions.

在C驱动器上的extarct和keep文件夹使用readme_precompile。三种指令。

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] value: OpenSSL’s include directory in your machine (e.g C:\openssl\include) or (e.g C:\openssl\include64) [Linker -> General -> Additional Library Directories] value: OpenSSL’s lib directory in your machine (e.g C:\openssl\lib) or (e.g C:\openssl\lib64) [Linker -> Input -> Additional Dependencies] value:

请确保在项目属性页中设置以下设置:[C/ c++ ->通用->附加包含目录]值:OpenSSL在您的机器中包含目录(e)。g C:\ openssl \包括)或(e。gc:\openssl\include64) [Linker -> General ->附加库目录]值:在您的机器上的openssl的lib目录(e。g C:\ openssl \ lib)或(e。gc:\openssl\lib64) [Linker ->输入->附加依赖项]值:

       ws2_32.lib
       libsslMT.lib
       Crypt32.lib 
       libcryptoMT.lib

#1


24  

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)

[C/ c++ ->通用->附加包括目录]值:OpenSSL在您的机器中包含目录(e)。g C:\ openssl \包括)

[Linker -> General -> Additional Library Directories] value: OpenSSL’s lib directory in your machine (e.g C:\openssl\lib)

[Linker ->通用->附加库目录]value:在你的机器上的OpenSSL的lib目录(e。g C:\ openssl \ lib)

[Linker -> Input -> Additional Dependencies] value: libeay32.lib

[Linker ->输入->附加依赖项]值:libeay32.lib。

Source.

源。

#2


3  

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不是我的强项,但也许你可以解决它。

#3


3  

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 link provided 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到配置属性-> Linker ->额外的库目录和openssl-1.0.1e\inc32的配置属性-> C/ c++ -> C/ c++ ->通用->附加包括目录,复制libeay32。dll在我的路径中,并称之为好。似乎工作。

#4


2  

Add openssl related headerfiles and below headers.

添加与openssl相关的头文件和下面的标题。

#include<windows.h>
#include<winsock2.h>

Open below Link & download pre-compiled files.

打开下面的链接和下载预编译文件。

http://www.npcglib.org/~stathis/blog/precompiled-openssl/

http://www.npcglib.org/ ~言/博客/ precompiled-openssl /

extarct and keep folder in C drive use readme_precompile.txt for instructions.

在C驱动器上的extarct和keep文件夹使用readme_precompile。三种指令。

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] value: OpenSSL’s include directory in your machine (e.g C:\openssl\include) or (e.g C:\openssl\include64) [Linker -> General -> Additional Library Directories] value: OpenSSL’s lib directory in your machine (e.g C:\openssl\lib) or (e.g C:\openssl\lib64) [Linker -> Input -> Additional Dependencies] value:

请确保在项目属性页中设置以下设置:[C/ c++ ->通用->附加包含目录]值:OpenSSL在您的机器中包含目录(e)。g C:\ openssl \包括)或(e。gc:\openssl\include64) [Linker -> General ->附加库目录]值:在您的机器上的openssl的lib目录(e。g C:\ openssl \ lib)或(e。gc:\openssl\lib64) [Linker ->输入->附加依赖项]值:

       ws2_32.lib
       libsslMT.lib
       Crypt32.lib 
       libcryptoMT.lib