Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
515 views
in Technique[技术] by (71.8m points)

c++ - using OpenSSL in Visual Studio 2012

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-Win32include)
  • Linker/General/Additional Library Directiories: C:OpenSSL-Win32lib
  • 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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...