While implementing code for SSL Handshake using Asio, the project does not build and throws error
C:\Eclipse\Boost\boost_1_62_0/boost/asio/ssl/detail/openssl_types.hpp:19:26: fatal error: openssl/conf.h: No such file or directory
So does it mean that for SSL using Asio we need to install OpenSSL ?
Well that's not the point i wanted to raise. The question is, is there any other alternate to use Asio SSL without asking client to install OpenSSL or in other words how can I statically bind OpenSSL with my application in a single executable?
boost::asio uses OpenSSLfor SSL sockets: if you have:
#include <boost/asio/ssl.hpp>
in your code, then you'll need to build with OpenSSL as well as boost.
To build with OpenSSL:
BOOST_NETWORK_ENABLE_HTTPS at project level;OpenSSL include directory to your include path;OpenSSL library directory to your library path, e.g. -L$${OPENSSL_ROOT}/lib;Windows, Visual Studio:
LIBS += -llibeay32
LIBS += -llibssleay32
Windows, MinGW:
LIBS += -lssl
LIBS += -lcrypto
Linux, GCC:
LIBS += -lssl
LIBS += -lcrypto
LIBS += -ldl
Note: you may have link issues with library order. I recommend including the OpenSSL libraries after the boost libraries; BTW boost::asio requires libboost_system.
can I statically bind OpenSSL with my application in a single executable?
Yes. You can build openssl with the no-shared option and it will only build a static library:
https://wiki.openssl.org/index.php/Compilation_and_Installation
and then just put the static archive on your link command line and it will be statically linked - but the people you distribute it to do not.
However, for you to link the program you have to have the header files and static library available to your compiler/linker.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With