How to use OpenSSL with Visual Studio [closed]

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.

Can anyone provide help using/linking the OpenSSL libs in a Visual Studio project?

Thanks!


Solution 1:

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).

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

Source.

Solution 2:

Add OpenSSL-related header files, and below headers:

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

Open below Link & download pre-compiled files.

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

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

Open Visual C++ project and followup procedure given in below to include and Linker options.

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

Solution 3:

Here are some resources: Compiling and installing OpenSSL for Windows, as well as Using OpenSSL for Cryptography (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.