cite from http://developer.covenanteyes.com/building-openssl-for-visual-studio/
and some edit..
==================================================
You need to install…
- Visual Studio 2015 (this will likely work with older versions as well)
- ActivePerl 1
- Latest version of OpenSSL source-code 2 or
$ git clone git://git.openssl.org/openssl.git
$ cd openssl $ git config core.autocrlf false $ git config core.eol lf $ git checkout .
- nasm ( http://www.nasm.us/pub/nasm/releasebuilds/2.11.08/win32/ )
Setting up for the build
Unzip3 the OpenSSL source code into two different folders, one for the 32-bit build and one for the 64-bit build4. So, for example, you might end up with C:openssl-src-32
and C:openssl-src-64
.
Building the 32-bit static libraries
- Open the Visual Studio Command Prompt (2010)5.
cd
to your OpenSSL source folder for 32-bit (e.g.cd C:openssl-src-32
).- Run the following: 6
1234perl Configure VC-WIN32 no-idea no-mdc2 no-rc5 —prefix=C:Build-OpenSSL-VC-32msdo_ms or msdo_nasmnmake -f msnt.mak or nmake -f msntdll.maknmake -f msnt.mak install or nmake -f msntdll.make install
Your outputs will be in C:Build-OpenSSL-VC-32
.
Building the 32-bit static libraries with debug symbols
These steps will embed the debug symbols directly into the .lib
files. Don’t expect to see any .pdb
files.
- Open the Visual Studio Command Prompt (2010).
cd
to your OpenSSL source folder for 32-bit (e.g.cd C:openssl-src-32
).- Run the following:
12perl Configure debug-VC-WIN32 no-idea no-mdc2 no-rc5 —prefix=C:Build-OpenSSL-VC-32-dbgmsdo_ms
- In a text editor (like Notepad), open
msnt.mak
and replace all occurrences of/Zi
with/Z7
. There should be three replacements.7 - Run the following:
12nmake -f msnt.maknmake -f msnt.mak install
Your outputs will be in C:Build-OpenSSL-VC-32-dbg
. Make sure you rename them to something like libeay32-debug.lib
and ssleay32-debug.lib
.
Building the 64-bit static libraries
- Open the Visual Studio x64 Win64 Command Prompt (2010) (in the Start menu).
cd
to your OpenSSL source folder for 64-bit (e.g.cd C:openssl-src-64
).- Run the following:
1234perl Configure VC-WIN64A no-idea no-mdc2 no-rc5 —prefix=C:Build-OpenSSL-VC-64msdo_win64anmake -f msnt.maknmake -f msnt.mak install
Your outputs will be in C:Build-OpenSSL-VC-64
.
Note: The outputs of the 64-bit build are still named libeay32.lib
and ssleay32.lib
. You’ll have to rename them more sensibly yourself.
Building the 64-bit static libraries with debug symbols
These steps will embed the debug symbols directly into the .lib
files. Don’t expect to see any .pdb
files.
- Open the Visual Studio x64 Win64 Command Prompt (2010).
cd
to your OpenSSL source folder for 64-bit (e.g.cd C:openssl-src-64
).- Run the following:
12perl Configure debug-VC-WIN64A no-idea no-mdc2 no-rc5 —prefix=C:Build-OpenSSL-VC-64-dbgmsdo_win64a
- In a text editor (like Notepad), open
msnt.mak
and replace all occurrences of/Zi
with/Z7
except on the line starting withASM
. There should be two replacements. 8 - Run the following:
12nmake -f msnt.maknmake -f msnt.mak install
Your outputs will be in C:Build-OpenSSL-VC-64-dbg
. Make sure you rename them to something like libeay64-debug.lib
and ssleay64-debug.lib
.
What not to do
I tried every method under the sun to get a Windows build of OpenSSL that would link against Visual Studio projects. I learned a great deal along the way. Here’s what I learned not to do:
- Don’t blindly follow the Windows 32-bit/64-bit installation instructions provided in the OpenSSL source folder. Get guidance online.
- Don’t build OpenSSL in Cygwin. It’s easy. It won’t link against Visual Studio.
- Don’t build OpenSSL in MSYS or MinGW. It’s hard. It won’t link against Visual Studio.
- Don’t try to use NASM like the Windows installation instructions mention. It’s not necessary for Visual Studio builds. (It only supports 32-bit anyway.)
- Strawberry Perl doesn’t always work in these weird configurations. ActivePerl seemed more stable.
- Don’t try to build 32-bit and 64-bit OpenSSL in the same folder. The first build will leave artifacts that will mess up the second build. (Running a clean isn’t enough, apparently.)
- Don’t try to build 32-bit OpenSSL inside of Visual Studio’s 64-bit command prompt and vice versa. It doesn’t work.
References
These were very helpful places:
Footnotes:
ms\ntdll.mak
will build the shared library instead.
/Zi
option works, but it’s hard to find the right .pdb
file without specifying more options. For the sake of simplicity, the /Z7
option just embeds all the debug symbols into the .lib
files. Read more here.
ml64.exe
) to compile assembly code. According to MASM’s documentation, the /Z7
option is not supported.
Could you cite your source? http://developer.covenanteyes.com/building-openssl-for-visual-studio/
i’m so sorry..
i’ll clearly mark the source..
This post is very useful. When I run
$ git clone git://git.openssl.org/openssl.git
I got
remote: warning: unable to access ‘/root/.config/git/attributes’: Permission denied
How to fix it? Shall I ignore it?
2
down vote
I think your HOME envireonment variable is improperly set.
From the google group thread,
the HOME environment variable was set to /root so it looked at /root/.gitconfig or /root/.config/git/config since the unprivileged user didn’t have access to /root it threw an error.
So the solution was for me to set the HOME env to the user’s HOME directory
I’m working in Windows 10 Command Line.
C:\ATEST>echo %HOMEPATH%
\Users\gchen
C:\ATEST>type \users\gchen\.gitconfig
[user]
name = gchen2101
[user]
email = chenlongsen@semptian.com
[filter “lfs”]
clean = git-lfs clean — %f
smudge = git-lfs smudge — %f
required = true
[credential]
set HOME=C:\ATEST
C:\ATEST>git clone git://git.openssl.org/openssl.git
Cloning into ‘openssl’…
remote: warning: unable to access ‘/root/.config/git/attributes’: Permission denied
remote: Counting objects: 217598, done.
^Cmote: Compressing objects: 0% (1/48054)
C:\ATEST>
I was confused with command “msdo_win64a”. I assume it meant “ms\do_win64a.bat”.
The same is true for “msnt.mak”.
This blog is very helpful, but it could be even more helpfull