|
To use curlpp we need libcurl. To use libcurl with secure protocols we need OpenSSL. It looks like it would be very helpfull to know how to build OpenSSL so that we can later use it while building or using libcurl.
From OpenSSL Project website:
The OpenSSL Project is a collaborative effort to develop a robust, commercial-grade, full-featured, and Open Source toolkit implementing the Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well as a full-strength general purpose cryptography library.
OpenSSL is used by libcurl to be able to use secure protocols; HTTPS, SFTP, FTPS and others.
The good news is OpenSSL supports win32 platform. The bad news is we have to take care about a couple of things before we can build different versions of libcurl library using different versions of OpenSSL library.
Libcurl's makefile for win32 platform can use Visual C++ naming convention for libraries it needs. This makes it possible to build different versions of libcurl library using different versions of OpenSSL library. Basically there can be two kinds (with respect to type of linking) of every windows library - dynamic (dll) and static. Additionally each of the above can be in release or debug version what gives us four possible kinds of Windows libraries - dynamic-release, dynamic-debug, static-release and static-debug. In Visual C++ naming convention each of these four kinds of Windows libraries has it's standard suffix:
- MD for dynamic-release
- MDd for dynamic-debug
- MT for static-release
- MTd for static-debug
(These suffixes come from names of Visual C++ compiler's options defining what kind of run-time library (RTL) to compile with.)
OpenSSL's makefile for win32 platform doesn't use this naming convention and names its output files libeay32.lib and ssleay32.lib by default regardless of build configuration chosen. Yet, it's flexible enough to change these names and that's what we need to do.
Building dynamic OpenSSL library
To support dynamic build types we need to change the following two lines in openssl-<version>/ms/ntdll.mak file
SSL=ssleay32 CRYPTO=libeay32
to
SSL=ssleay32MD CRYPTO=libeay32MD
Additionally before building dynamic versions of the library we have to change the following line in the openssl-<version>/ms/libeay32.def file
LIBRARY LIBEAY32
to
LIBRARY LIBEAY32MD
and analogically the following line in the openssl-<version>/ms/ssleay32.def file
LIBRARY SSLEAY32
to
LIBRARY SSLEAY32MD
Building static OpenSSL library
To support static build types we only need to change the following two lines in openssl-<version>/ms/nt.mak file
SSL=ssleay32 CRYPTO=libeay32
to
SSL=ssleay32MT CRYPTO=libeay32MT
Building debug OpenSSL library
If we want to build debug versions of the library as well we have to change the following two lines in openssl-<version>/ms/do_ms.bat file;
perl util\mk1mf.pl no-asm VC-WIN32 >ms\nt.mak perl util\mk1mf.pl dll no-asm VC-WIN32 >ms\ntdll.mak
adding debug as an extra argument
perl util\mk1mf.pl debug no-asm VC-WIN32 >ms\nt.mak perl util\mk1mf.pl debug dll no-asm VC-WIN32 >ms\ntdll.mak
Also, instead of using MD/MT suffixes in the above steps we should use MDd/MTd ones.
In the result, after running four modified makefiles we should get all four kinds of OpenSSL libraries -
- ssleay32MD.dll, ssleay32MD.lib and libeay32MD.dll, libeay32MD.lib (for dynamic-release build)
- ssleay32MDd.dll, ssleay32MDd.lib and libeay32MDd.dll, libeay32MDd.lib (for dynamic-debug build)
- ssleay32MT.lib and libeay32MT.lib (for static-release build)
- ssleay32MTd.lib and libeay32MTd.lib (for static-debug build)
Now, we can put all above libraries in one folder and after setting appropriate paths in libcurl's makefile for win32 platform, we can use this libraries to build all four kinds of libcurl libraries in turn.
You can read about building OpenSSL on Windows in this article on wiki.php.net
Happy building!
|