40

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!

jww
  • 97,681
  • 90
  • 411
  • 885
  • 3
    Did you install Win32 OpenSSL? If not, go here: http://slproweb.com/products/Win32OpenSSL.html – Chris Gessler Jul 08 '12 at 14:52
  • What is the licence it carries ? I am not sure if it can be included in a commercial product... any ideas can help –  Jul 09 '12 at 02:17
  • 1
    Do you have the OpenSSL windows lib with you? What problem are you exactly facing when you try to link with OpenSSL Libs? – Jay Jul 09 '12 at 11:43
  • [\[SO\]: How to include openssl in Visual Studio Expres 2012 Windows 7 x64](https://stackoverflow.com/questions/32156336/how-to-include-openssl-in-visual-studio-expres-2012-windows-7-x64). – CristiFati Feb 28 '18 at 18:53
  • 1
    This is NOT too broad. It has quite a specific solution. – rustyx Jul 06 '18 at 07:34

4 Answers4

39

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.

Community
  • 1
  • 1
joker
  • 3,416
  • 2
  • 34
  • 37
  • Hi joker can you please explain the install process. That link doesnt have any exe to run. I cloned from github, but am now stuck. – Noitidart Dec 28 '16 at 04:26
  • 1
    @Noitidart, what OS are you using? – joker Dec 29 '16 at 17:50
  • Thanks very much @joker for your reply. I have been struggling really hard. I am on Win10, I created this topic explaining what I did and asking for help - http://stackoverflow.com/q/41357374/1828637 – Noitidart Dec 29 '16 at 19:22
  • 4
    Just install one from here: https://slproweb.com/products/Win32OpenSSL.html I have used this method. – joker Dec 29 '16 at 19:44
  • Thanks @Joker! I will try it out. Also I'm new to C++, I just want to make sure, when I `#include` these, then my users won't have to install OpenSSL too right? They can use it even if its not installed? – Noitidart Dec 29 '16 at 19:58
  • 1
    I'm not really about this part. I think (possibly) that if you compile the project as a release, this will omit the need at the user end to install the library. Meaning, if I am correct, when you compile the project, the user doesn't need to install the library. I'm not sure though. – joker Dec 30 '16 at 18:50
  • Thanks joker for your thoughts I really appreciate it. – Noitidart Dec 30 '16 at 22:50
14

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
caf
  • 233,326
  • 40
  • 323
  • 462
Nagaraj Gaonkar
  • 141
  • 1
  • 3
4

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.

Dr1Ku
  • 2,875
  • 3
  • 47
  • 56
Nitesh
  • 1,241
  • 4
  • 16
  • 25
4

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:

I tried using the PERL that comes with git, didn't work, had to install ActivePerl

Taken from the link provided by Nitesh:

perl Configure VC-WIN64A no-asm

Followed by:

ms\do_win64a

Per this post, I edited ms\ntdll.mak and changed CC to:

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.

Community
  • 1
  • 1
  • 1
    This is the "build openssl from source" approach, if all you want to do is compile against it, it's much easier to get the binaries. – Mike Ounsworth Jul 30 '15 at 18:49