1. OpenSSL 다운로드
http://www.openssl.org/source/openssl-0.9.8k.tar.gz
2. ActivePerl 설치
openssl 라이브러리를 컴파일 하기 위해서는 perl 이 필요합니다.
http://downloads.activestate.com/ActivePerl/Windows/5.10/ActivePerl-5.10.0.1004-MSWin32-x86-287188.msi
다운로드 받은 ActivePerl을 설치합니다. (※ 설치시 Next 버튼만 계속 누르면 됩니다. ^^)
3. 전반적인 컴파일 환경 구축
압축이 해제된 디렉토리로 이동하여, 아래와 같이 명령어를 입력합니다.
> perl Configure VC-WIN32 --openssldir=C:\OpenSSL-x86-debug no-shared no-asm threads
참고로 --openssldir=C:\OpenSSL 과 같이 입력하면 "C:\OpenSSL" 디렉토리에 라이브러리가 설치됩니다.
4. 구체적인 컴파일 환경 구축
컴파일 환경은 다음과 같이 3가지 유형중 한 가지를 선택하여 사용이 가능합니다.
어셈블리어를 사용하지 않는 경우 ms\do_ms.bat
NASM 어셈블리어를 사용하는 경우 ms\do_nasm.bat
MASM 어셈블리어를 사용하는 경우 ms\do_masm.bat
만약, 어셈블리어를 사용하지 않을 경우에는, 아래와 같이 명령어를 입력합니다.
5. 소스 수정
윈도우 환경에서는 아래와 같은 파일을, OpenSSL을 컴파일 하기 이전에 수정해 주어야 합니다.
(아마 다음 OpenSSL 버전에서는 필요없는 과정이 될 수도 있겠군요.. ^^;;)
1) openssl-0.9.8k\crypto\x509v3\v3_pci.c
소스파일 최상단에 위치한 주석문에 특수문자가 포함되어 있어서 컴파일 오류가 발생하기 때문에,
소스파일 가장 위에 주석문을 제거하고 저장함.
2) openssl-0.9.8k\crypto\x509v3\v3_pcia.c
소스파일 최상단에 위치한 주석문에 특수문자가 포함되어 있어서 컴파일 오류가 발생하기 때문에,
소스파일 가장 위에 주석문을 제거하고 저장함.
3) openssl-0.9.8k\crypto\cversion.c
cversion.c 105 번째 라인을 아래와 같이 수정함.
[수정 전] return "OPENSSLDIR: \"" OPENSSLDIR "\"";
[수정 후] return "OPENSSLDIR: \" OPENSSLDIR \"";
4) openssl-0.9.8k\crypto\cryptlib.h
cryptlib.h 84~86번째 라인을 아래와 같이 수정함.
5) openssl-0.9.8k\crypto\opensslconf.h
opensslconf.h 107~108번째 라인을 아래와 같이 수정함.
6. 컴파일 및 설치
정적 라이브러리 빌드 인 경우 : nmake -f ms\nt.mak install
동적 라이브러리 빌드 인 경우 : nmake -f ms\ntdll.mak install
만약, 동적 라이브러리 컴파일 및 설치를 위해서는 아래와 같이 명령어를 입력합니다.
7. 설치 결과
첨부된 "OpenSSL.zip"파일은 윈도우 환경에서 OpenSSL을 컴파일한 결과물을 압축한 파일입니다.
OpenSSL.zip
8. 테스트 코드
#include <stdio.h>
#include <openssl/ssl.h>
#include <openssl/rand.h>
int main(int argc, char **argv)
{
int nRand = 0;
RAND_bytes((unsigned char *)&nRand, 1);
printf("Random number is %d\n", nRand);
return 0;
}
9. OpenSSL x64 컴파일 및 설치
[출처] http://stackoverflow.com/questions/158232/how-do-you-compile-openssl-for-x64
|
To compile the static libraries (both release and debug), this is what you need to do:
- Install Perl - www.activestate.com
- Run the "Visual Studio 2008 x64 Cross Tools Command Prompt" (Note: The regular command prompt WILL NOT WORK.)
- Configure with perl Configure VC-WIN64A no-shared no-idea
- Run: ms\do_win64a
- EDIT ms\nt.mak and change "32" to "64" in the output dirs:
# The output directory for everything intersting
OUT_D=out64.dbg
# The output directory for all the temporary muck
TMP_D=tmp64.dbg
# The output directory for the header files
INC_D=inc64
INCO_D=inc64\openssl
- EDIT ms\nt.mak and remove bufferoverflowu.lib from EX_LIBS if you get an error about it.
- Run: nmake -f ms\nt.mak
- EDIT the ms\do_win64a file and ADD "debug" to all lines, except the "ml64" and the last two lines
- Run: ms\do_win64a
- Repeat steps 4 and 5
- EDIT the ms\nt.mak file and ADD /Zi to the CFLAG list!
- Run: nmake -f ms\nt.mak
|
Itanium 장비환경에서는
perl configure VC-WIN64I no-shared no-idea --openssldir=C:\OpenSSL
ms\do_win64i.bat