title: Trying to include OpenSSL headers in Visual Studio 2012: error LNK2019: unresolved external symbol
body: <p>I know this problem is pretty common. In fact, I searched a lot about the problem but I can't find any solution which fits my case.
  I'm working in a C++ Visual Studio 2012 project which uses openssl libraries.
  This is a minimum sample code.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;stdio.h&gt;
  //OpenSSL
  #include &lt;openssl/bio.h&gt;
  #include &lt;openssl/ssl.h&gt;
  #include &lt;openssl/err.h&gt;
  #include &lt;openssl/x509.h&gt;
  
  using namespace std;
  
  int main(){
      SSL_library_init ();
  
      return 0;
  }
  </code></pre>
  
  <p>I'm running Visual Studio 2012 Proffesional in a Windows7-64b machine.
  I downloaded the <strong>Win64 OpenSSL v1.0.1e Light installer</strong> from <a href="http://slproweb.com/products/Win32OpenSSL.html" rel="nofollow">here</a>
  and installed it. Then I added to <strong>Project Properties-> Configuration Properties-> C/C++-> General-> Additional Include Directories</strong> the path "C:\OpenSSL-Win64\include".
  So by this moment, the sample code is not showing compilation errors in Visual Studio.
  Then, I also added to the <strong>Linker-> Additional library directories</strong>, the path "C:\OpenSSL-Win64\lib" and then in <strong>Linker-> Additional Dependencies</strong>, I added "libeay32.lib;" and "ssleay32.lib".
  However, when I tried to compile I got this error:</p>
  
  <pre><code>1&gt;------ Build started: Project: Client, Configuration: Debug Win32 ------
  1&gt;  Client.cpp
  1&gt;Client.obj : error LNK2019: unresolved external symbol _SSL_library_init referenced in function _main
  1&gt;c:\users\gabi\documents\visual studio 2012\Projects\Project1\Debug\Client.exe : fatal error LNK1120: 1 unresolved externals
  ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  </code></pre>
  
  <p>I also tried with the rest of the OpenSSL libraries, because it's possible that SSL_init_function() doesn't belong to "libeay32.lib" or "ssleay32.lib". So I added in the source code :</p>
  
  <pre><code>#pragma comment(lib, "libeay32.lib")
  #pragma comment(lib, "ssleay32.lib")
  #pragma comment(lib, "VC\\libeay32MD.lib")
  #pragma comment(lib, "VC\\libeay32MDd.lib")
  #pragma comment(lib, "VC\\libeay32MT.lib")
  #pragma comment(lib, "VC\\libeay32MTd.lib")
  #pragma comment(lib, "VC\\ssleay32MD.lib")
  #pragma comment(lib, "VC\\ssleay32MDd.lib")
  #pragma comment(lib, "VC\\ssleay32MT.lib")
  #pragma comment(lib, "VC\\ssleay32MTd.lib")
  </code></pre>
  
  <p>Those are all the libraries, except the ones which are in the subfolder "VC\static", because the files in static folder have the same name as some of those and it could be a conflict.
  Anyway, the error it's the same. 
  Oh, I also added the string "C:\OpenSSL-Win64\bin" to the PATH environment variable.
  And...I also tried by linking to the Win32 OpenSSL which I installed too, and compiling my own "libeay32.lib" and "ssleay32.lib" following <a href="http://developer.covenanteyes.com/building-openssl-for-visual-studio/" rel="nofollow">this tutorial</a>. Both, 32b or 64b didn't work.
  I'm quite desperate with this, can anyone help me?
  Thanks!</p>