** This post is based on http://crowback.tistory.com/entry/openssl-098i-버전-윈도우-환경하에서-컴파일하기 and INSTALL.W32 (plain text file that comes with the openSSL source)

I had to build openSSL on Windows platform at work. Since it's not something that will work simply as opening a solution file on visual studio and building it, I'm keeping a record on how I did it. Not that this is something really difficult, I hope this information can become handy for the ones who really need it.

The requirements...
- cl (Microsoft c/c++ compiler)
- ml (MASM - Microsoft macro assember)
- perl

My build evironment...
- cl: Visual C++ 2005 express (can download here)
- ml: Microsoft macro assember 8 (can download MASM here)
- perl: v5.10.0 built for cygwin-thread-multi-64int (can download cygwin here)
* Prior to building openSSL, check if cl and ml can be executed from command prompt by simply typing 'cl' and 'ml'. If cl and ml is properly executed, you can see the version and usage of cl or ml you are executing. If it seems like cl and ml is not being executed properly, refer to the following by extending "더보기".

1. Downloading Source Files and Extracting it
Download  Openssl-0.9.8j.tar.gz from http://www.openssl.org/source/ and extract it to a dedicated folder. In my case D:\Work\openssl-0.9.8j.
(tar.gz files open beautifully with 7-zip, which is a freeware that supports unpacking almost every compression format widely used these days)


2. Configure
Execute "Configure" perl script by typing the following in the command prompt, where the prefix argument specifies where openSSL will be installed. In my case c:\openssl.
> perl Configure VC-WIN32 --prefix=c:\openssl


3. Add Assembly Functions
Add assembly functions (really don't know what it means at the moment) by typing the following from the command prompt.
> ms\do_masm


4. Make the following modifications to files
4-1. in crypto\cversion.c line 105
return "OPENSSLDIR: \"" OPENSSLDIR "\"";

return "OPENSSLDIR: \" OPENSSLDIR \"";

4-2. in crypto\cryptlib.c line 84~86
#define X509_CERT_DIR  OPENSSLDIR "/certs"
#define X509_CERT_FILE  OPENSSLDIR "/cert.pem"
#define X509_PRIVATE_DIR OPENSSLDIR "/private"

#define X509_CERT_DIR  OPENSSLDIR "\\certs"
#define X509_CERT_FILE  OPENSSLDIR "\\cert.pem"
#define X509_PRIVATE_DIR OPENSSLDIR "\\private"

4-3. in crypto\opensslconf.h line 107~108
(the dir path may differ depending on the argument used for prefix when configuring)
#define ENGINESDIR "c:\openssl/lib/engines"
#define OPENSSLDIR "c:\openssl/ssl"

#define ENGINESDIR "c:\\openssl\\lib\\engines"
#define OPENSSLDIR "c:\\openssl\\ssl"


5. Build, Test, Install
> nmake -f ms\ntdll.mak <- to build
> nmake -f ms\ntdll.mak test <- to test if build was successful
> nmake -f ms\ntdll.mak install <- to install openSSL






Posted by Dansoonie