Windows下安装Openssl安装详解
准备工作:VC6.0以上版本的编译器、最新版的Openssl压缩包(http://www.)、最新版本的Perl(http://downloads.)。安装工作:
参考openssl目录下的install.win32说明进行安装:
1、进入解压目录
>cd C:\openssl-0.9.8a\ openssl-0.9.8a
2、运行Configure
>perl Configure VC-WIN32
如不成功会有明显提示。
3、创建Makefile文件
>ms\do_ms
推荐使用这种方式,另外两种方式如果使用也必须保证本机有编译器才能使用。
:ms\do_masm (默认vc 自带的编译器;也可以自己下载安装)
:ms\do_nasm (需要自己下载)
4、配置VC环境变量。
>cd C:\Program Files\Microsoft Visual Studio\VC98\Bin
>vcvars32.bat
5、编译动态链接库。
>cd C:\openssl-0.9.8a
>nmake -f ms\ntdll.mak
如果编译成功,最后的输出都在out32dll目录下:包括可执行文件、两个dll(ssleay32.lib, libeay32.lib)和两个lib文件(ssleay32.dll, libeay32.dll)。
6、为VC添加头文件和静态链接库路径。
ToolsOptionsDirectores,在Include files中增加C:\openssl-0.9.8k \inc32目录;在Libray files中增加C:\openssl-0.9.8k\out32dll。
7、编写OpenSSL程序,可参考C:\openssl-0.9.8k\demos
(1)包含相应头文件
#include <openssl/***.h>
(2) 添加静态链接库
#pragma comment(lib, "libeay32.lib")
#pragma comment(lib, "ssleay32.lib")
或ProjectSettingsLinkObject\library modules填写libeay32.lib ssleay32.lib。
(3)将动态链接库ssleay32.dll, libeay32.dll复制到C:\WINDOWS\system32或Debug目录下,确保动态链接库在正确的路径。
附件
在DOS中安装实例:
Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.
C:\DOCUME~1\user\LOCALS~1\Temp\Rar$EX01.313>cd C:\openssl-0.9.8a\openssl-0.9.8a
C:\openssl-0.9.8a\openssl-0.9.8a>perl Configure VC-WIN32
Configuring for VC-WIN32
no-gmp [default] OPENSSL_NO_GMP (skip dir)
no-krb5 [krb5-flavor not specified] OPENSSL_NO_KRB5
no-mdc2 [default] OPENSSL_NO_MDC2 (skip dir)
no-rc5 [default] OPENSSL_NO_RC5 (skip dir)
no-shared [default]
no-zlib [default]
no-zlib-dynamic [default]
IsMK1MF=1
CC =cl
CFLAG =-DOPENSSL_THREADS -DDSO_WIN32
EX_LIBS =
CPUID_OBJ =
BN_ASM =bn_asm.o
DES_ENC =des_enc.o fcrypt_b.o
AES_ASM_OBJ =aes_core.o aes_cbc.o
BF_ENC =bf_enc.o
CAST_ENC =c_enc.o
RC4_ENC =rc4_enc.o
RC5_ENC =rc5_enc.o
MD5_OBJ_ASM =
SHA1_OBJ_ASM =
RMD160_OBJ_ASM=
PROCESSOR =
RANLIB =true
ARFLAGS =
PERL =perl
THIRTY_TWO_BIT mode
BN_LLONG mode
RC4_INDEX mode
RC4_CHUNK is undefined
Configured for VC-WIN32.
C:\openssl-0.9.8a\openssl-0.9.8a>ms\do_ms
C:\openssl-0.9.8a\openssl-0.9.8a>perl util\mkfiles.pl 1>MINFO
C:\openssl-0.9.8a\openssl-0.9.8a>perl util\mk1mf.pl no-asm VC-WIN32 1>ms\nt.mak
C:\openssl-0.9.8a\openssl-0.9.8a>perl util\mk1mf.pl dll no-asm VC-WIN32 1>ms\ntdll.mak
C:\openssl-0.9.8a\openssl-0.9.8a>perl util\mk1mf.pl no-asm VC-CE 1>ms\ce.mak
%OSVERSION% is not defined at util/pl/VC-32.pl line 37.
Compilation failed in require at util\mk1mf.pl line 129.
C:\openssl-0.9.8a\openssl-0.9.8a>perl util\mk1mf.pl dll no-asm VC-CE 1>ms\cedll.mak
%OSVERSION% is not defined at util/pl/VC-32.pl line 37.
Compilation failed in require at util\mk1mf.pl line 129.
C:\openssl-0.9.8a\openssl-0.9.8a>perl util\mkdef.pl 32 libeay 1>ms\libeay32.def
C:\openssl-0.9.8a\openssl-0.9.8a>perl util\mkdef.pl 32 ssleay 1>ms\ssleay32.def
C:\openssl-0.9.8a\openssl-0.9.8a>cd c:\Program Files\Microsoft Visual Studio\VC98\Bin
C:\Program Files\Microsoft Visual Studio\VC98\Bin>vcvars32.bat
Setting environment for using Microsoft Visual C++ tools.
C:\Program Files\Microsoft Visual Studio\VC98\Bin>cd C:\openssl-0.9.8a\openssl-0.9.8a
C:\openssl-0.9.8a\openssl-0.9.8a>nmake -f ms\ntdll.mak
Microsoft (R) Program Maintenance Utility Version 6.00.8168.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.
Building OpenSSL
copy nul+ .\crypto\buildinf.h tmp32dll\buildinf.h
nul
.\crypto\buildinf.h
已复制 1 个文件。
copy nul+ .\crypto\opensslconf.h inc32\openssl\opensslconf.h
nul
.\crypto\opensslconf.h
已复制 1 个文件。
rc /fo"tmp32dll\libeay32.res" /d CRYPTO ms\version32.rc
link /nologo /subsystem:console /machine:I386 /opt:ref /dll /out:out32dll\libeay32.dll /def:ms/LIBEAY32.def @C:\DOCUME~1\user\LOCALS~1\Temp\nma00216.
Creating library out32dll\libeay32.lib and object out32dll\libeay32.exp
rc /fo"tmp32dll\ssleay32.res" /d SSL ms\version32.rc
link /nologo /subsystem:console /machine:I386 /opt:ref /dll /out:out32dll\ssleay32.dll /def:ms/SSLEAY32.def @C:\DOCUME~1\user\LOCALS~1\Temp\nmb00216.
Creating library out32dll\ssleay32.lib and object out32dll\ssleay32.exp
link /nologo /subsystem:console /machine:I386 /opt:ref /out:out32dll\md2test.exe @C:\DOCUME~1\user\LOCALS~1\Temp\nmc00216.
Creating library tmp32dll\junk.lib and object tmp32dll\junk.exp
link /nologo /subsystem:console /machine:I386 /opt:ref /out:out32dll\md4test.exe @C:\DOCUME~1\user\LOCALS~1\Temp\nmd00216.
Creating library tmp32dll\junk.lib and object tmp32dll\junk.exp
link /nologo /subsystem:console /machine:I386 /opt:ref /out:out32dll\md5test.exe @C:\DOCUME~1\user\LOCALS~1\Temp\nme00216.
Creating library tmp32dll\junk.lib and object tmp32dll\junk.exp
link /nologo /subsystem:console /machine:I386 /opt:ref /out:out32dll\shatest.exe @C:\DOCUME~1\user\LOCALS~1\Temp\nmf00216.
Creating library tmp32dll\junk.lib and object tmp32dll\junk.exp
link /nologo /subsystem:console /machine:I386 /opt:ref /out:out32dll\sha1test.exe @C:\DOCUME~1\user\LOCALS~1\Temp\nmg00216.
Creating library tmp32dll\junk.lib and object tmp32dll\junk.exp
link /nologo /subsystem:console /machine:I386 /opt:ref /out:out32dll\sha256t.exe @C:\DOCUME~1\user\LOCALS~1\Temp\nmh00216.
Creating library tmp32dll\junk.lib and object tmp32dll\junk.exp
link /nologo /subsystem:console /machine:I386 /opt:ref /out:out32dll\sha512t.exe @C:\DOCUME~1\user\LOCALS~1\Temp\nmi00216.
Creating library tmp32dll\junk.lib and object tmp32dll\junk.exp
link /nologo /subsystem:console /machine:I386 /opt:ref /out:out32dll\hmactest.exe @C:\DOCUME~1\user\LOCALS~1\Temp\nmj00216.
Creating library tmp32dll\junk.lib and object tmp32dll\junk.exp
link /nologo /subsystem:console /machine:I386 /opt:ref /out:out32dll\rmdtest.exe @C:\DOCUME~1\user\LOCALS~1\Temp\nmk00216.
Creating library tmp32dll\junk.lib and object tmp32dll\junk.exp
link /nologo /subsystem:console /machine:I386 /opt:ref /out:out32dll\destest.exe @C:\DOCUME~1\user\LOCALS~1\Temp\nml00216.
Creating library tmp32dll\junk.lib and object tmp32dll\junk.exp
link /nologo /subsystem:console /machine:I386 /opt:ref /out:out32dll\rc2test.exe @C:\DOCUME~1\user\LOCALS~1\Temp\nmm00216.
Creating library tmp32dll\junk.lib and object tmp32dll\junk.exp
link /nologo /subsystem:console /machine:I386 /opt:ref /out:out32dll\rc4te
st.exe @C:\DOCUME~1\user\LOCALS~1\Temp\nmn00216.
Creating library tmp32dll\junk.lib and object tmp32dll\junk.exp
link /nologo /subsystem:console /machine:I386 /opt:ref /out:out32dll\ideatest.exe @C:\DOCUME~1\user\LOCALS~1\Temp\nmo00216.
Creating library tmp32dll\junk.lib and object tmp32dll\junk.exp
link /nologo /subsystem:console /machine:I386 /opt:ref /out:out32dll\bftest.exe @C:\DOCUME~1\user\LOCALS~1\Temp\nmp00216.
Creating library tmp32dll\junk.lib and object tmp32dll\junk.exp
link /nologo /subsystem:console /machine:I386 /opt:ref /out:out32dll\casttest.exe @C:\DOCUME~1\user\LOCALS~1\Temp\nmq00216.
Creating library tmp32dll\junk.lib and object tmp32dll\junk.exp
link /nologo /subsystem:console /machine:I386 /opt:ref /out:out32dll\bntest.exe @C:\DOCUME~1\user\LOCALS~1\Temp\nmr00216.
Creating library tmp32dll\junk.lib and object tmp32dll\junk.exp
link /nologo /subsystem:console /machine:I386 /opt:ref /out:out32dll\exptest.exe @C:\DOCUME~1\user\LOCALS~1\Temp\nms00216.
Creating library tmp32dll\junk.lib and object tmp32dll\junk.exp
link /nologo /subsystem:console /machine:I386 /opt:ref /out:out32dll\rsa_test.exe @C:\DOCUME~1\user\LOCALS~1\Temp\nmt00216.
Creating library tmp32dll\junk.lib and object tmp32dll\junk.exp
link /nologo /subsystem:console /machine:I386 /opt:ref /out:out32dll\dsatest.exe @C:\DOCUME~1\user\LOCALS~1\Temp\nmu00216.
Creating library tmp32dll\junk.lib and object tmp32dll\junk.exp
link /nologo /subsystem:console /machine:I386 /opt:ref /out:out32dll\dhtest.exe @C:\DOCUME~1\user\LOCALS~1\Temp\nmv00216.
Creating library tmp32dll\junk.lib and object tmp32dll\junk.exp
link /nologo /subsystem:console /machine:I386 /opt:ref /out:out32dll\ectest.exe @C:\DOCUME~1\user\LOCALS~1\Temp\nmw00216.
Creating library tmp32dll\junk.lib and object tmp32dll\junk.exp
link /nologo /subsystem:console /machine:I386 /opt:ref /out:out32dll\ecdhtest.exe @C:\DOCUME~1\user\LOCALS~1\Temp\nmx00216.
Creating library tmp32dll\junk.lib and object tmp32dll\junk.exp
link /nologo /subsystem:console /machine:I386 /opt:ref /out:out32dll\ecdsatest.exe @C:\DOCUME~1\user\LOCALS~1\Temp\nmy00216.
Creating library tmp32dll\junk.lib and object tmp32dll\junk.exp
link /nologo /subsystem:console /machine:I386 /opt:ref /out:out32dll\randtest.exe @C:\DOCUME~1\user\LOCALS~1\Temp\nmz00216.
Creating library tmp32dll\junk.lib and object tmp32dll\junk.exp
link /nologo /subsystem:console /machine:I386 /opt:ref /out:out32dll\evp_test.exe @C:\DOCUME~1\user\LOCALS~1\Temp\nna00216.
Creating library tmp32dll\junk.lib and object tmp32dll\junk.exp
link /nologo /subsystem:console /machine:I386 /opt:ref /out:out32dll\enginetest.exe @C:\DOCUME~1\user\LOCALS~1\Temp\nnb00216.
Creating library tmp32dll\junk.lib and object tmp32dll\junk.exp
link /nologo /subsystem:console /machine:I386 /opt:ref /out:out32dll\ssltest.exe @C:\DOCUME~1\user\LOCALS~1\Temp\nnc00216.
Creating library tmp32dll\junk.lib and object tmp32dll\junk.exp
link /nologo /subsystem:console /machine:I386 /opt:ref /out:out32dll\openssl.exe @C:\DOCUME~1\user\LOCALS~1\Temp\nnd00216.
Creating library tmp32dll\junk.lib and object tmp32dll\junk.exp
C:\openssl-0.9.8a\openssl-0.9.8a>^C