Building OpenSSL for Visual Studio

Source: Internet
Author: User
Tags gz file openssl version openssl windows

Labels: Visual Studio OpenSSL windows Perl

This test is effective for bloggers.

Reprinted please indicate the source: http://blog.csdn.net/xiaoy_h/article/details/36444013

Original English post: http://developer.covenanteyes.com/building-openssl-for-visual-studio/

Translation:

It is quite simple to generate OpenSSL that supports vs on windows, but simple things are twists and turns. I will write down this twists and turns here to reduce the pain points in future experiments.

(It's really emotional to speak outside China)


What do you need to do?

You need to install:

Vs2010 (this will be most likely compatible with earlier versions)

ActivePerl [1]

The latest OpenSSL source-code [2]


Generate Configuration

Decompress [3] OpenSSL source code to two folders, one for 32-bit generation and the other for 64-bit [4 ]. For example, you can extract to c: \ openssl-src-32 and c: \ openssl-src-64 directory.


Generate a 32-bit static library

1. Open the Visual Studio command prompt (2010) [5]

2, CD command to enter the 32-bit source code directory (such as: cd c: \ openssl-src-32 ).

3. Run the following command: [6]

perl Configure VC-WIN32 --prefix=C:\Build-OpenSSL-VC-32ms\do_msnmake -f ms\nt.mak nmake -f ms\nt.mak install
Will eventually be generated in the C: \ Build-OpenSSL-VC-32. Directory


Generate a 32-bit static library for debugging

These steps will directly embed the debugging identifier into the Lib file. Do not expect to see any PDB files.

1. Open the command prompt above.

2, the same as CD into the source directory (or c: \ openssl-src-32)

3. Execute the following command:

perl Configure debug-VC-WIN32 --prefix=C:\Build-OpenSSL-VC-32-dbgms\do_ms
4. Open the MS \ nt. Mak file in a text editor similar to notepad and replace all/Zi with/z7. Three will be replaced. [7]

5. Execute the following command:

nmake -f ms\nt.maknmake -f ms\nt.mak install
Finally generated in the directory c: \ Build-OpenSSL-VC-32-dbg. And change some files to the following names: libeay32-debug.lib and ssleay32-debug.lib


Generate a 64-bit static library

1. Open the Visual Studio x64 command prompt (find it in the Start menu)

2, CD into the OpenSSL 64-bit source code folder (e.g. cd c: \ openssl-src-64)

3. Run the following command:

perl Configure VC-WIN64A --prefix=C:\Build-OpenSSL-VC-64ms\do_win64anmake -f ms\nt.maknmake -f ms\nt.mak install
This will output in the C: \ Build-OpenSSL-VC-64 directory

Note: The output names are libeay32.lib and ssleay32.lib. You must change the name to the corresponding name (to avoid confusion ).


Generate a 64-bit static library with a debug character

These steps will directly embed the debugging identifier into the Lib file. Do not expect to see any PDB files.
1. Open the Visual Studio x64 Command Prompt

2, CD into the OpenSSL 64-bit source code folder (e.g. cd c: \ openssl-src-64)

3. Run the following command:

perl Configure debug-VC-WIN64A --prefix=C:\Build-OpenSSL-VC-64-dbgms\do_win64a
4. In the text editor, edit the file the same as above. In addition to the line starting with ASM, replace it twice. [8]

5. Run the following command:

nmake -f ms\nt.maknmake -f ms\nt.mak install
This will output in this directory: C: \ Build-OpenSSL-VC-64-dbg. The colleague's name should also be changed like this: libeay64-debug.lib and ssleay64-debug.lib.

Do not do anything?

I tried every method in sun that can be linked to the vs project to obtain the Windows generation of OpenSSL. I learned a lot on this road. These are what I know not to do:

-Do not blindly follow the Win32/64 installation commands in the OpenSSL source code directory. Go to the Internet to find a guide.

-Do not generate OpenSSL in cygwin. This is simple, but cannot be linked to.

-Do not create OpenSSL in msys and mingw. This is very difficult and cannot be successfully linked to.

-Do not use the Windows Installation command to do the mentioned NASM, which is unnecessary for vs build. (In any case, it only supports 32 bits .)

-Strawberry Perl is not always valid in these wonderful configurations. ActivePerl seems to be more stable.

-Do not create 32-bit and 64-bit OpenSSL in the same directory. The first generation operation will leave some "relics" in the directory, which will disrupt the second generation operation. (Obviously, executing a clean statement is far from enough .)

-Do not try to create 32-bit OpenSSL in the 64-bit command prompt of Vs, and vice versa. This will not have any effect.


Reference

The following are useful urls:

Https://github.com/freelan-developers/freelan-buildtools/blob/master/INSTALL.md


Footer:

[1]. Do not use strawberry Perl (you can view post comments ).

[2]. OpenSSL version 1.0.1c is the latest version of this article.

You can easily uncompress the .tar.gz file on Windows. This is a two-step process.

[4] OpenSSL generation script is not intelligent enough for building on two platforms in one queue. The generation of different platforms must start from scratch.

[5]. You can find him somewhere in the Start Menu.

[6]. Using MS \ NTDLL. Mak generates a shared library.

[7]. Although the/Zi option is useful, it is difficult to find the correct. PDB file without specifying more options. Simply put, the/z7 option only embeds all debugging identifiers into the Lib file. Here we will look at more details.

For 64-bit generation, vsuses masm(ml64.exe) to compile assembly code. Depending on the MASM's documentation, the/z7 option is not supported.




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.