1. Compiling OpenSSL For Windows
Introduction
In order to support more advanced features planned in future releases, ClamAV has switched to
using OpenSSL for hashing. The ClamAV Visual Studio project included with ClamAV’s
source code requires the OpenSSL distributables to be placed in a specific directory. This article will
teach you how to compile OpenSSL on a Microsoft Windows system and how to link ClamAV against
OpenSSL.
This blog article is based on another article.
Prerequisites
You will need ActiveState ActivePerl installed. OpenSSL uses Perl-based Makefiles. You will also
need Visual Studio 2010 or later.
Download OpenSSL
You can find OpenSSL’s source here. Download the latest version. When this article was first
authored, the latest version of OpenSSL was 1.0.1h. This article will reference that version
throughout.
We will be using separate build and installation directories for 32bit and 64bit compilations.
We’ll extract the source code twice, to C:openssl-src-32 and C:openss-src-64. We’ll
then create two directories to hold the OpenSSL installation: C:openssl-build-32 and C:openssl-
build-64.
Compiling OpenSSL
2. We will first build the 32bit libraries. You will need to open a Visual Studio 32bit command prompt.
Please note that you cannot build OpenSSL 64bit from a 32bit Visual Studio command prompt and
vice-versa.
We’ll run these commands in the command prompt:
C:
cd openssl-src-32
perl Configure VC-WIN32—prefix=C:openssl-build-32
msdo_ms
nmake -f msntdll.mak
nmake -f msntdll.mak install
Once those commands have run, you’ll need to create the 64bit OpenSSL distributables in a
Visual Studio x64 comamnd prompt:
C:
cd openssl-src-64
perl Configure VC-WIN64A—prefix=C:openssl-build-64
msdo_win64a
nmake -f msntdll.mak
nmake -f msntdll.mak install
You now have both the 32bit and 64bit builds of OpenSSL compiled and installed in their respective
build directories.
ClamAV Dependencies Directory
Now that you have distributables for both 32bit and 64bit, we’ll now need to create the
directories where the ClamAV Visual Studio project expects the OpenSSL dependencies to be.
Create these directories:
C:clamdeps
C:clamdepswin32
C:clamdepswin32openssl
C:clamdepswin32openssllib
3. C:clamdepswin64
C:clamdepswin64openssl
C:clamdepswin64openssllib
Copy the 32bit directories and files over:
C:openssl-build-32include to C:clamdepswin32openssl
C:openssl-build-32liblibeay32.lib to C:clamdepswin32openssllib
C:openssl-build-32libssleay32.lib to C:clamdepswin32openssllib
C:openssl-build-32binlibeay32.dll to C:clamdepswin32openssllib
C:openssl-build-32binssleay32.dll to C:clamdepswin32openssllib
Now copy the 64bit directories and files over:
C:openssl-build-64include to C:clamdepswin64openssl
C:openssl-build-64liblibeay32.lib to C:clamdepswin64openssllib
C:openssl-build-64libssleay32.lib to C:clamdepswin64openssllib
C:openssl-build-64binlibeay32.dll to C:clamdepswin64openssllib
C:openssl-build-64binssleay32.dll to C:clamdepswin64openssllib
Conclusion
We’ve now built the OpenSSL libraries that ClamAV now depends on. ClamAV requires them
to be in C:clamdepswin32,64openssl.