6

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

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.

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!

UPDATE

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

The steps required to use the openSSL lib with VS2012:

  • 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 :

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

  • Copy theese files into current VS folder /VC/lib
Community
  • 1
  • 1
rdanee
  • 109
  • 1
  • 1
  • 9

1 Answers1

5

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?

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

Thomas
  • 3,074
  • 1
  • 25
  • 39
  • I think the pre built ones is a good choice, Now I have downloaded (Win64 OpenSSL v1.0.1e, I have 64bit W7), installed it. In OpenSSL-Win64 directory there are the includes, and in the lib the .libs. What should I do now? SHall I Copy them into VS directory, or what should I config in VS? – rdanee Jun 16 '13 at 08:16
  • I set C/C++/General/Additional Include Dirs to OpenSSL-Win64/include, OpenSSL-Win64/lib, and I set the dependencies to libeay32.lib, ssleay32.lib. I have the same problem – rdanee Jun 16 '13 at 08:17
  • It's the correct way to do it. Are you sure you have included the VC directory? for example C:\OpenSSL-WinXX\lib\VC or C:\OpenSSL-WinXX\lib\VC\static for static libs. Then link against MT libs for release and MTd for debug builds. (libeay32MT.lib, ...) – Thomas Jun 16 '13 at 10:31
  • Make also sure your platform matches, VC builds 32 bit binaries by default. – Thomas Jun 16 '13 at 10:40
  • I updated my question with the solution. Thank you for your idea, to download pre built openssl, that helped me to find the way. :) – rdanee Jun 17 '13 at 20:15
  • If I just included those folders where the libs are, It did not work. :( When I copied them to Visual Studio's VC/lib folder, it worked. – rdanee Jun 17 '13 at 20:16
  • Well, great you got it to working, but it is the wrong way how to do it, never(!) copy any third party libs into the VC directory. From what I can see, I think you have not included the VC library dir of OpenSSL, but instead the MinGW one. You may also have the OpenSSL libraries in two directories, which may mean, VC is seeing the 32 bit libs first, and spits out "unresolved symbol" errors. I am using the same OpenSSL distribution, without polluting my VC dir, and it works without any problem. – Thomas Jun 18 '13 at 14:12