Compile openssl on win10

本次编译环境

  1. os version:windows 10 professional x64
  2. JDK1.8
  3. Perl 5.24.2
  4. Visual Studio 2017
  5. NASM 2.12.0.2

配置环境

下载perl

ActiveState.com下载perl并安装
如果一切顺利的话

C:\Perl64\eg>cd C:\Perl64\eg
C:\Perl64\eg>perl example.pl
Hello from ActivePerl!
C:\Perl64\eg>

下载openssl

下载openssl
解压至:

C:\openssl-1.0.2m

下载NASM

下载[NASM],安装后,需要配置path环境变量

编译openssl

  1. 打开vs Command Prompt

**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.0.26430.15
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community>cd C:\openssl-1.0.2m
C:\openssl-1.0.2m>perl Configure VC-WIN64A no-asm --prefix=d:\openssl_lib
Configuring for VC-WIN64A
no-asm [option] OPENSSL_NO_ASM
no-ec_nistp_64_gcc_128 [default] OPENSSL_NO_EC_NISTP_64_GCC_128 (skip dir)
no-gmp [default] OPENSSL_NO_GMP (skip dir)
no-jpake [experimental] OPENSSL_NO_JPAKE (skip dir)
no-krb5 [krb5-flavor not specified] OPENSSL_NO_KRB5
no-libunbound [experimental] OPENSSL_NO_LIBUNBOUND (skip dir)
no-md2 [default] OPENSSL_NO_MD2 (skip dir)
no-rc5 [default] OPENSSL_NO_RC5 (skip dir)
no-rfc3779 [default] OPENSSL_NO_RFC3779 (skip dir)
no-sctp [default] OPENSSL_NO_SCTP (skip dir)
no-shared [default]
no-ssl-trace [default] OPENSSL_NO_SSL_TRACE (skip dir)
no-ssl2 [default] OPENSSL_NO_SSL2 (skip dir)
no-store [experimental] OPENSSL_NO_STORE (skip dir)
no-unit-test [default] OPENSSL_NO_UNIT_TEST (skip dir)
no-weak-ssl-ciphers [default] OPENSSL_NO_WEAK_SSL_CIPHERS (skip dir)
no-zlib [default]
no-zlib-dynamic [default]
IsMK1MF=1
CC =cl
CFLAG =-DOPENSSL_THREADS -DDSO_WIN32 -W3 -Gs0 -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_DEPRECATE
EX_LIBS =
CPUID_OBJ =mem_clr.o
BN_ASM =bn_asm.o
EC_ASM =
DES_ENC =des_enc.o fcrypt_b.o
AES_ENC =aes_core.o aes_cbc.o
BF_ENC =bf_enc.o
CAST_ENC =c_enc.o
RC4_ENC =rc4_enc.o rc4_skey.o
RC5_ENC =rc5_enc.o
MD5_OBJ_ASM =
SHA1_OBJ_ASM =
RMD160_OBJ_ASM=
CMLL_ENC =camellia.o cmll_misc.o cmll_cbc.o
MODES_OBJ =
ENGINES_OBJ =
PROCESSOR =
RANLIB =true
ARFLAGS =
PERL =perl
SIXTY_FOUR_BIT mode
DES_INT used
RC4_CHUNK is unsigned long long

Configured for VC-WIN64A.

C:\openssl-1.0.2m>ms\do_win64a

C:\openssl-1.0.2m>goto proceed

C:\openssl-1.0.2m>perl util\mk1mf.pl VC-WIN64A 1>ms\nt.mak

C:\openssl-1.0.2m>perl util\mk1mf.pl dll VC-WIN64A \1>ms\ntdll.mak

C:\openssl-1.0.2m>perl util\mkdef.pl 32 libeay 1>ms\libeay32.def

C:\openssl-1.0.2m>perl util\mkdef.pl 32 ssleay 1>ms\ssleay32.def

C:\openssl-1.0.2m>nmake -f ms\ntdll.mak

最终编译完成后会输出至d:\openssl_lib

参考文章

  1. http://blog.csdn.net/u010725842/article/details/50295235
  2. https://wiki.openssl.org/index.php/Compilation_and_Installation#Windows
  3. http://developer.covenanteyes.com/building-openssl-for-visual-studio/