Building OpenSSL with Visual Studio

Downloads

I provide downloads for Visual Studio 2010 and 2015. I had to remove my 2013 installation due to space constraints, but the build files are still there so you can do it, too.

Version Visual Studio 2010 Visual Studio 2015
OpenSSL 1.0.2d 32-Bit Release DLL 32-Bit Release DLL
  32-Bit Debug DLL 32-Bit Debug DLL
  32-Bit Release Static Library 32-Bit Release Static Library
  32-Bit Debug Static Library 32-Bit Debug Static Library
  64-Bit Release DLL 64-Bit Release DLL
  64-Bit Debug DLL 64-Bit Debug DLL
  64-Bit Release Static Library 64-Bit Release Static Library
  64-Bit Debug Static Library 64-Bit Debug Static Library
OpenSSL 1.0.1p 32-Bit Release DLL 32-Bit Release DLL
  32-Bit Debug DLL 32-Bit Debug DLL
  32-Bit Release Static Library 32-Bit Release Static Library [broken]
  32-Bit Debug Static Library 32-Bit Debug Static Library [broken]
  64-Bit Release DLL 64-Bit Release DLL
  64-Bit Debug DLL 64-Bit Debug DLL
  64-Bit Release Static Library 64-Bit Release Static Library [broken]
  64-Bit Debug Static Library 64-Bit Debug Static Library [broken]

Building OpenSSL automatically

Because the process of building OpenSSL is time consuming and error prone, I wrote a couple of batch scripts that simplify the process significantly. You can download them here. Inside, you will find three batch files:

  • rebuild_openssl_vs2010.cmd for use with Visual Studio 2010
  • rebuild_openssl_vs2013.cmd for use with Visual Studio 2013
  • rebuild_openssl_vs2015.cmd for use with Visual Studio 2015

Prerequisites

  • The script assumes you are on Windows.
  • The script assumes you have Visual Studio 2010, 2013 or 2015 installed in all the usual places. Important: If you have a different installation folder, your mileage may vary
  • The script assumes you have downloaded an OpenSSL tarball, like this one.
  • The script assumes you have Python (2.7 or 3.x) installed and on your PATH
  • The script assumes you have 7-zip installed (doesn't need to be on your PATH)
  • Choose the script you want to use and edit it. For example, let's take a look at the top of rebuild_openssl_vs2015.cmd:
    T:
    set OPENSSL_VERSION=1.0.1p
    set SEVENZIP="C:\Program Files\7-Zip\7z.exe"
    set VS2015="C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\vcvars32.bat"
    set VS2015_AMD64="C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat"
    

    so it is pretty easy to see: you must enter the OpenSSL version manually, the rest should have sensible defaults...

  • Note: The script uses the SUBST T:\ drive for building OpenSSL.

Building the OpenSSL binaries

  • Place the tar.gz file (not the unpacked .tar) in the root of T:\
  • Double-click on one of the rebuild_openssl-vs*.cmd.

That's it, it will do all the hard work for you and present nicely packaged binaries. Great fun!

Building OpenSSL manually

OK, so you don't trust me. Right. Well, here is how you can do it manually.... Note: This article wouldn't have been possible without the invaluable help of this article. However, it was obviously not built on a Windows 8 machine, and it didn't include any binaries. So this article follows the same basic structure, but it has some important differences:

  • The instructions default to the DLL build
    Why? because that is the one used by Python. And because I was rebuilding Python, I was rebuilding OpenSSL in the first place. So there.
  • Debug build uses .PDBs

Prerequisites

  • You need Visual Studio 2010, 2013 or 2015.
  • You need to install Perl. I used ActivePerl 5.16.3 for Windows (x86).
  • You need the OpenSSL sourcecode. In the following, both the 1.0.1 and 1.0.2 branches are supported.
  • Unzip the sourcecode.
  • Create two different copies of the sourcecode. I am going to follow the conventions of the original article and create T:\openssl-src-32 and T:\openssl-src-64.
  • You need a development prompt. This varies based on your compiler:
    • Visual Studio 2010, 32-bit: Open Visual Studio Command Prompt (2010)
    • Visual Studio 2010, 64-bit: Open Visual Studio x64 Win64 Command Prompt (2010)
    • Visual Studio 2013, 32-bit: Open CMD.EXE and run C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat
    • Visual Studio 2013, 64-bit: Open CMD.EXE and run C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64\vcvars64.bat
    • Visual Studio 2015, 32-bit: Open CMD.EXE and run C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\vcvars32.bat
    • Visual Studio 2015, 64-bit: Open CMD.EXE and run C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat

Building the 32-bit Release DLL

  • Change to the source directory, for example T:\openssl-src-32
  • Run perl Configure VC-WIN32 --prefix=T:\Build-OpenSSL-VC32-Release-DLL. This will make T:\Build-OpenSSL-VC32-Release-DLLyour output directory; it should be fairly obvious how you can change that.
  • Run ms\do_ms
  • If you are on the 1.0.2 branch, you must do the following: Run ms\do_nasm.
    This step is not necessary if you are on 1.0.1
  • Run nmake -f ms\ntdll.mak
  • Run nmake -f ms\ntdll.mak install

Building the 32-bit Debug DLL

  • Change to the source directory, for example T:\openssl-src-32
  • Run perl Configure debug-VC-WIN32 --prefix=T:\Build-OpenSSL-VC32-Debug-DLL
  • Run ms\do_ms
  • If you are on the 1.0.2 branch, you must do the following: Run ms\do_nasm.
    This step is not necessary if you are on 1.0.1
  • Run nmake -f ms\ntdll.mak
  • Run nmake -f ms\ntdll.mak install

Building the 32-bit Release Static Library

  • Change to the source directory, for example T:\openssl-src-32
  • Run perl Configure VC-WIN32 --prefix=T:\Build-OpenSSL-VC32-Release-DLL. This will make T:\Build-OpenSSL-VC32-Release-DLLyour output directory; it should be fairly obvious how you can change that.
  • Run ms\do_ms
  • If you are on the 1.0.2 branch, you must do the following: Run ms\do_nasm.
    This step is not necessary if you are on 1.0.1
  • Run nmake -f ms\nt.mak
  • Run nmake -f ms\nt.mak install

Building the 32-bit Debug Static Library

  • Change to the source directory, for example T:\openssl-src-32
  • Run perl Configure debug-VC-WIN32 --prefix=T:\Build-OpenSSL-VC32-Debug-DLL
  • Run ms\do_ms
  • If you are on the 1.0.2 branch, you must do the following: Run ms\do_nasm.
    This step is not necessary if you are on 1.0.1
  • Run nmake -f ms\nt.mak
  • Run nmake -f ms\nt.mak install

Building the 64-bit Release DLL

  • Change to the source directory, for example T:\openssl-src-64
  • Run perl Configure VC-WIN64A --prefix=T:\Build-OpenSSL-VC64-Release-DLL. This will make T:\Build-OpenSSL-VC64-Release-DLL your output directory; it should be fairly obvious how you can change that.
  • Run ms\do_win64a
  • Run nmake -f ms\ntdll.mak
  • Run nmake -f ms\ntdll.mak install

Building the 64-bit Debug DLL

  • Change to the source directory, for example T:\openssl-src-64
  • Run perl Configure debug-VC-WIN64A --prefix=T:\Build-OpenSSL-VC64-Debug-DLL
  • Run ms\do_win64a
  • Run nmake -f ms\ntdll.mak
  • Run nmake -f ms\ntdll.mak install

Building the 64-bit Release Static Library

  • Change to the source directory, for example T:\openssl-src-32
  • Run perl Configure VC-WIN64A --prefix=T:\Build-OpenSSL-VC64-Release-Static. This will make T:\Build-OpenSSL-VC64-Release-Static your output directory; it should be fairly obvious how you can change that.
  • Run ms\do_win64a
  • Run nmake -f ms\nt.mak
  • Run nmake -f ms\nt.mak install

Building the 64-bit Debug Static Library

  • Change to the source directory, for example T:\openssl-src-64
  • Run perl Configure debug-VC-WIN64A --prefix=T:\Build-OpenSSL-VC64-Debug-DLL
  • Run ms\do_win64a
  • Run nmake -f ms\nt.mak
  • Run nmake -f ms\nt.mak install

FAQ

Why did I need to create two different copies of the sourcecode

Because the OpenSSL build scripts will use the folder outdll32 for both the 32-bit and the 64-bit output, so there is no easy way to distinguish both builds.



GK, December 12, 2015

Note: Special thanks to Alex (see https://github.com/CpServiceSpb/OpenSSLOcsp) for pointing out some mistakes in the documentation of the 64-bit build. Should be fine now.

时间: 2024-10-01 20:47:57

Building OpenSSL with Visual Studio的相关文章

Building OpenSSL for Visual Studio

Building OpenSSL for Visual Studio on Windows is mostly straight-forward, but it has some quirks. I'll document the results of my wrestling here so that future attempts will be less painful. What you need You need to install- Visual Studio 2010 (see

openssl 安装问题-visual studio下 openssl安装问题

问题描述 visual studio下 openssl安装问题 按照以上步骤进行安装,首先在第五部就出现问题,最后在 visualstudio 运行ms命令才通过..但是最后生成不了.dll文件 解决方案 具体错误是什么信息 看自带说明文档 解决方案二: http://blog.csdn.net/xielechuan/article/details/6254140

在 Windows 上使用 Visual Studio 编译 CURL

导语: 教你科学地编译 Windows 版本的 libcurl (使用Windows SSPI或者OpenSSL) 准备工具 CMake (3.4.0) Zlib (1.2.8) libcurl (7.45.0) OpenSSL (1.0.2d) Visual Studio 2015 目标 得到可以使用的 libcurl 静态库 步骤 编译Zlib 打开CMake,把 Zlib 目录下的 CMakeList.txt 拖进去,生成解决方案,这一步不能用 contrib\vstudio 下的 sln

Visual Studio .NET Enterprise Architect 中基于 Visio 的数据库建模:第二部分

enterprise|visual|数据|数据库  Terry HalpinMicrosoft Corporation 2001年11月 摘要:本文是介绍 Microsoft Visual Studio Enterprise Architect 中基于 Visio 的数据库建模组件系列文章中的第二篇.第一部分讨论了如何创建新的对象角色建模 (ORM) 源模型,如何在 fact editor(事实编辑器)中添加句子类型.基本内部约束及示例,如何将事实类型从 business rules edito

给开心的:Visual Studio .NET Custom Wizards

visual Visual Studio .NET supports a number of built in project types and wizards that generate skeleton projects and solutions depending on the type of application the developer intend to build. These project templates are an excellent way to automa

Visual Studio 2008 、 Windows 环境变量介绍 和 如何在文件中引用环境变量 .

Visual Studio 2008  和 Windows 环境变量对设置 相对路径很重要,这样便于代码的移植,即使换一台计算机,代码不用更改配置,直接就能用. 可以在项目的"工具""属性页"对话框中任何接受字符串的位置使用这些宏.这些宏不区分大小写.  关于如何自己定义环境变量详见我的另一文章:http://blog.csdn.net/jtop0/article/details/7574139     宏 说明 $(RemoteMachine) 在"调试

Visual Studio 2013教你如何使用MVC5

本文主要讲的是利用Visual Studio 2013手把手教你构建一个入门的ASP.NET MVC5 Web应用程序.本教程配套的C#源码工程可通过如下网址下载:C#版本源码链接.不仅如此,你还可以通过查阅Building the Chapter Downloads 来完成编译源码和配置数据库.您可在Visual Studio中运行MVC 5应用程序.您也可以使Web应用程序部署到一个托管服务提供商上.微软提供免费的网络托管多达10个网站,free Windows Azure trial ac

Visual Studio 2017 : client version 1.22 is too old

使用Vs2017 编译 eShopOnContainers-ServicesAndWebApps 时,报了错误: Microsoft.DotNet.Docker.CommandLineClientException: client version 1.22 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version. For more troubleshootin

用好Visual Studio 2010进行层架构设计

微软已经把VS 2010(Visual Studio 2010 Ultimate)功能融入到软件应用生命周期管理(ALM)中.在架构设计方面则是通过新的架构层关系图(Architecture Layer Diagram),以图形化的方式描述系统架构,从而使得项目中的技术人员或非技术人员都能以模型透过图形化的方式进行协作与设计,以及定义企业的系统功能. Visual Studio 2010提供针对不同功能层面的分析工具来辅助程序代码进行逆向工程.Layer Diagram可从高阶面来看架构:Arc