环境:
win10_x64家庭中文版,VS2017旗舰版
开始:
一、安装工具
1. 安装ActivePerl
2. 安装nasm
验证安装是否安装成功:
perl -version
nasm -v
二、下载源码
1. openssl-OpenSSL_0_9_8g.tar.gz 解压到D:/openssl-OpenSSL_0_9_8g
查看openssl版本:opensslv.h #define OPENSSL_VERSION_TEXT "OpenSSL 0.9.8g 19 Oct 2007"
三、编译
1. 编写脚本build.bat
@echo off ::Release,Debug set BUILD_TYPE=%1% if not "%BUILD_TYPE%" == "Release" if not "%BUILD_TYPE%" == "Debug" ( echo "BUILD_TYPE:%BUILD_TYPE% ERROR" exit /b ) ::x86,x64 set PLATFORM=%2% if not "%PLATFORM%" == "x86" if not "%PLATFORM%" == "x64" ( echo "PLATFORM:%PLATFORM% ERROR" exit /b ) ::Dynamic,Static set LIBRARY=%3% if not "%LIBRARY%" == "Dynamic" if not "%LIBRARY%" == "Static" ( echo "LIBRARY:%LIBRARY% ERROR" exit /b ) set CURRENT_DIR=%~dp0 if exist "C:Program Files (x86)Microsoft Visual Studio2017EnterpriseVCAuxiliaryBuild" ( set BUILD_TOOL="C:Program Files (x86)Microsoft Visual Studio2017EnterpriseVCAuxiliaryBuild" ) else if exist "C:Program FilesMicrosoft Visual Studio2017EnterpriseVCAuxiliaryBuild" ( set BUILD_TOOL="C:Program FilesMicrosoft Visual Studio2017EnterpriseVCAuxiliaryBuild" ) else if exist "D:Program Files (x86)Microsoft Visual Studio2017EnterpriseVCAuxiliaryBuild" ( set BUILD_TOOL="D:Program Files (x86)Microsoft Visual Studio2017EnterpriseVCAuxiliaryBuild" ) else if exist "D:Program FilesMicrosoft Visual Studio2017EnterpriseVCAuxiliaryBuild" ( set BUILD_TOOL="D:Program FilesMicrosoft Visual Studio2017EnterpriseVCAuxiliaryBuild" ) else if exist "E:Program Files (x86)Microsoft Visual Studio2017EnterpriseVCAuxiliaryBuild" ( set BUILD_TOOL="E:Program Files (x86)Microsoft Visual Studio2017EnterpriseVCAuxiliaryBuild" ) else if exist "E:Program FilesMicrosoft Visual Studio2017EnterpriseVCAuxiliaryBuild" ( set BUILD_TOOL="E:Program FilesMicrosoft Visual Studio2017EnterpriseVCAuxiliaryBuild" ) else ( echo "BUILD_TOOL ERROR" goto end ) echo "BUILD_TOOL=%BUILD_TOOL%" ::if not defined VS150COMNTOOLS ( if "%PLATFORM%" == "x86" ( call %BUILD_TOOL%vcvars32.bat" ) if "%PLATFORM%" == "x64" ( call %BUILD_TOOL%vcvars64.bat ) ::) if "%PLATFORM%" == "x86" ( if "%BUILD_TYPE%" == "Release" ( perl Configure VC-WIN32 no-asm --prefix=%CURRENT_DIR%%PLATFORM% ) if "%BUILD_TYPE%" == "Debug" ( perl Configure debug-VC-WIN32 no-asm --prefix=%CURRENT_DIR%%PLATFORM% ) ) else if "%PLATFORM%" == "x64" ( if "%BUILD_TYPE%" == "Release" ( perl Configure VC-WIN64A no-asm --prefix=%CURRENT_DIR%%PLATFORM% ) if "%BUILD_TYPE%" == "Debug" ( perl Configure debug-VC-WIN64A no-asm --prefix=%CURRENT_DIR%%PLATFORM% ) ) ::exit /b call msdo_nasm.bat call msdo_win64a.bat if "%LIBRARY%" == "Dynamic" ( ::动态库 echo y|nmake -f ms tdll.mak clean call nmake -f ms tdll.mak call nmake -f ms tdll.mak test call nmake -f ms tdll.mak install ) else if "%LIBRARY%" == "Static" ( ::静态库 echo y|nmake -f ms t.mak clean call nmake -f ms t.mak call nmake -f ms t.mak test call nmake -f ms t.mak install )
2. 编译