SSL Enhancement with Visual Studio 2010 and OpenSSL

I am trying to compile examples of servers and clients of Boost 1.47 ASIO SSL and clients. I can successfully include Boost in my project, but I cannot include OpenSSL. When I try to add it, I get errors:

1>SSLServer.obj : error LNK2019: unresolved external symbol _ERR_reason_error_string referenced in function "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall boost::asio::error::detail::ssl_category::message(int)const " ( ?message@ssl _category@detail @ error@asio @ boost@ @ UBE?AV?$basic_string@DU ?$char_traits@D @ std@ @ V?$allocator@D @ 2@ @ std@ @ H@Z ) 1>SSLServer.obj : error LNK2019: unresolved external symbol _CRYPTO_set_id_callback referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::do_init(void)" ( ??0do_init@openssl _init_base@detail @ ssl@asio @ boost@ @ QAE@XZ ) 1>SSLServer.obj : error LNK2019: unresolved external symbol _CRYPTO_set_locking_callback referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::do_init(void)" ( ??0do_init@openssl _init_base@detail @ ssl@asio @ boost@ @ QAE@XZ ) 1>SSLServer.obj : error LNK2019: unresolved external symbol _CRYPTO_num_locks referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::do_init(void)" ( ??0do_init@openssl _init_base@detail @ ssl@asio @ boost@ @ QAE@XZ ) 1>SSLServer.obj : error LNK2019: unresolved external symbol _SSL_load_error_strings referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::do_init(void)" ( ??0do_init@openssl _init_base@detail @ ssl@asio @ boost@ @ QAE@XZ ) 1>SSLServer.obj : error LNK2019: unresolved external symbol _SSL_library_init referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::do_init(void)" ( ??0do_init@openssl _init_base@detail @ ssl@asio @ boost@ @ QAE@XZ ) 1>SSLServer.obj : error LNK2019: unresolved external symbol _ENGINE_cleanup referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::~do_init(void)" ( ??1do_init@openssl _init_base@detail @ ssl@asio @ boost@ @ QAE@XZ ) 1>SSLServer.obj : error LNK2019: unresolved external symbol _CONF_modules_unload referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::~do_init(void)" ( ??1do_init@openssl _init_base@detail @ ssl@asio @ boost@ @ QAE@XZ ) 1>SSLServer.obj : error LNK2019: unresolved external symbol _CRYPTO_cleanup_all_ex_data referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::~do_init(void)" ( ??1do_init@openssl _init_base@detail @ ssl@asio @ boost@ @ QAE@XZ ) 1>SSLServer.obj : error LNK2019: unresolved external symbol _EVP_cleanup referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::~do_init(void)" ( ??1do_init@openssl _init_base@detail @ ssl@asio @ boost@ @ QAE@XZ ) 1>SSLServer.obj : error LNK2019: unresolved external symbol _ERR_remove_state referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::~do_init(void)" ( ??1do_init@openssl _init_base@detail @ ssl@asio @ boost@ @ QAE@XZ ) 1>SSLServer.obj : error LNK2019: unresolved external symbol _ERR_free_strings referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::~do_init(void)" ( ??1do_init@openssl _init_base@detail @ ssl@asio @ boost@ @ QAE@XZ ) 1>C:\Users\Epicism\Documents\Visual Studio 2010\Projects\SSLServer\Debug\SSLServer.exe : fatal error LNK1120: 12 unresolved externals 1> 1>Build FAILED. 

I tried to add the directory C: \ OpenSSL-Win32 \ lib \, C: \ OpenSSL-Win32 \ lib \ VC \, C: \ OpenSSL-Win32 \ lib \ VC \ static, C: \ OpenSSL-Win32 \ bin, C: \ OpenSSL-Win32 \ include in Project-> General Properties-> Linker-> Additional libraries using pre-compiled openssl libraries (http://www.openssl.org/related/binaries.html). I also tried compiling OpenSSL with the same errors. I am really at a loss, I tried everything I searched on Google, about a thousand times, tried IRC, every combination of directories that I can think of ...

My setup: Windows 7 64-bit Windows 64-bit version of Visual Studio 2010 Boost 1.47 OpenSSL 1.0.0E and G C / C ++ Additional directories: C: \ Program Files (x86) \ boost \ boost_1_47; C: \ openssl \ include \; C: \ OpenSSL-Win32 \ lib;% (AdditionalIncludeDirectories) Project-> General Properties-> Linker-> Additional Libraries: C: \ Program Files (x86) \ boost \ boost_1_47 \ lib; C: \ openssl \ lib; C: \ openssl;% (AdditionalLibraryDirectories) - I tried adding all directories to this property ...

Now I'm just trying to compile the following in a VS C ++ console project:

//SSLServer.cpp: Defines the entry point for the console application. //

 #include "stdafx.h" #include <cstdlib> #include <iostream> #include <boost/bind.hpp> #include <boost/asio.hpp> #include <boost/asio/ssl.hpp> int _tmain(int argc, _TCHAR* argv[]) { return 0; } 

Thanks in advance.

+5
source share
3 answers

It looks like you are using the 32-bit version of OpenSSL on a 64-bit machine.

Try downloading the 64-bit version (Win64 OpenSSL v1.0.0g) from http://www.slproweb.com/products/Win32OpenSSL.html

After that (if you use the default paths), you should have the C:\OpenSSL-Win64 folder.

You must add:

  • C:\OpenSSL-Win64\include to your additional Include directories
  • C:\OpenSSL-Win64\lib\VC\static or C:\OpenSSL-Win64\lib\VC in your additional library directories depending on whether you want static libraries or dll libraries respectively
  • libeay32<XXX>.lib and ssleay32<XXX>.lib for additional dependencies, where <XXX> matches any parameter set to [C/C++]->[Code Generation]->[Runtime Library]
+10
source

I managed to build your little program above by linking it to the 32-bit version of the Boost library along with the 32-bit version of OpenSSL. You will also need a 32-bit version of redistributables . The error is present in Boost versions 1.51 and 1.52, which are the only versions I tested.

I believe that there is an error in the 64-bit version of the ASIO library. Although, it is possible that this is some kind of configuration problem that has affected many others. I submitted a Boost error report about this problem.

+3
source

I met a similar problem (VS2010) solved by methods:

1) Properties-> C / C ++ → general-> additional include Directories: your path \ boost_1_58_0 \ boost_1_58_0 (I use version 1.58.0)

2) Properties-> Linker → general-> additional library directories: yourpath \ boost_1_58_0 \ boost_1_58_0 \ stage \ Lib

3) Properties-> Linker → Input → Additional Dependencies: libeay32.lib ssleay32.lib

These two .lib files are copied from the openssl installation directory.

0
source

Source: https://habr.com/ru/post/947379/


All Articles