How to Compile Openssl for X64

Build OpenSSL for both x64 and x86 (side-by-side installation)?

The unified diff below was created for openssl-1.0.2h and will allow building both the x86 (win32) and x64 (win64) versions without conflicts using visual studio. Nothing changes with the build instructions included with openssl, you simple run the perl configure, the ms/do_xxx, and then nmake the build, and nmake the install. You do those for x64 and x86 environment without having to undo anything from the prior build.

+++ Configure   Mon Jan 19 14:26:32 1970
@@ -584,10 +584,10 @@
# Visual C targets
#
# Win64 targets, WIN64I denotes IA-64 and WIN64A - AMD64
-"VC-WIN64I","cl:-W3 -Gs0 -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_DEPRECATE:::WIN64I::SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT EXPORT_VAR_AS_FN:ia64cpuid.o:ia64.o ia64-mont.o:::aes_core.o aes_cbc.o aes-ia64.o::md5-ia64.o:sha1-ia64.o sha256-ia64.o sha512-ia64.o:::::::ghash-ia64.o::ias:win32",
-"VC-WIN64A","cl:-W3 -Gs0 -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_DEPRECATE:::WIN64A::SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT EXPORT_VAR_AS_FN:".eval{my $asm=$x86_64_asm;$asm=~s/x86_64-gcc\.o/bn_asm.o/;$asm}.":auto:win32",
-"debug-VC-WIN64I","cl:-W3 -Gs0 -Gy -Zi -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_DEPRECATE:::WIN64I::SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT EXPORT_VAR_AS_FN:ia64cpuid.o:ia64.o:::aes_core.o aes_cbc.o aes-ia64.o::md5-ia64.o:sha1-ia64.o sha256-ia64.o sha512-ia64.o:::::::ghash-ia64.o::ias:win32",
-"debug-VC-WIN64A","cl:-W3 -Gs0 -Gy -Zi -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_DEPRECATE:::WIN64A::SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT EXPORT_VAR_AS_FN:".eval{my $asm=$x86_64_asm;$asm=~s/x86_64-gcc\.o/bn_asm.o/;$asm}.":auto:win32",
+"VC-WIN64I","cl:-W3 -Gs0 -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_DEPRECATE:::WIN64I::SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT EXPORT_VAR_AS_FN:ia64cpuid.o:ia64.o ia64-mont.o:::aes_core.o aes_cbc.o aes-ia64.o::md5-ia64.o:sha1-ia64.o sha256-ia64.o sha512-ia64.o:::::::ghash-ia64.o::ias:win64",
+"VC-WIN64A","cl:-W3 -Gs0 -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_DEPRECATE:::WIN64A::SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT EXPORT_VAR_AS_FN:".eval{my $asm=$x86_64_asm;$asm=~s/x86_64-gcc\.o/bn_asm.o/;$asm}.":auto:win64",
+"debug-VC-WIN64I","cl:-W3 -Gs0 -Gy -Zi -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_DEPRECATE:::WIN64I::SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT EXPORT_VAR_AS_FN:ia64cpuid.o:ia64.o:::aes_core.o aes_cbc.o aes-ia64.o::md5-ia64.o:sha1-ia64.o sha256-ia64.o sha512-ia64.o:::::::ghash-ia64.o::ias:win64",
+"debug-VC-WIN64A","cl:-W3 -Gs0 -Gy -Zi -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_DEPRECATE:::WIN64A::SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT EXPORT_VAR_AS_FN:".eval{my $asm=$x86_64_asm;$asm=~s/x86_64-gcc\.o/bn_asm.o/;$asm}.":auto:win64",
# x86 Win32 target defaults to ANSI API, if you want UNICODE, complement
# 'perl Configure VC-WIN32' with '-DUNICODE -D_UNICODE'
"VC-WIN32","cl:-W3 -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE:::WIN32::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}:${x86_asm}:win32n:win32",
@@ -2078,11 +2078,21 @@
VALUE "FileDescription", "OpenSSL Shared Library\\0"
VALUE "FileVersion", "$version\\0"
#if defined(CRYPTO)
+ #if defined(_WIN64)
+ VALUE "InternalName", "libeay64\\0"
+ VALUE "OriginalFilename", "libeay64.dll\\0"
+ #else
VALUE "InternalName", "libeay32\\0"
VALUE "OriginalFilename", "libeay32.dll\\0"
+ #endif
#elif defined(SSL)
+ #if defined(_WIN64)
+ VALUE "InternalName", "ssleay64\\0"
+ VALUE "OriginalFilename", "ssleay64.dll\\0"
+ #else
VALUE "InternalName", "ssleay32\\0"
VALUE "OriginalFilename", "ssleay32.dll\\0"
+ #endif
#endif
VALUE "ProductName", "The OpenSSL Toolkit\\0"
VALUE "ProductVersion", "$version\\0"
@@ -2262,23 +2272,23 @@
{
@fields = split(/\s*:\s*/,$table{$target} . ":" x 30 , -1);

- if ($fields[$idx_dso_scheme-1] =~ /^(beos|dl|dlfcn|win32|vms)$/)
+ if ($fields[$idx_dso_scheme-1] =~ /^(beos|dl|dlfcn|win32|win64|vms)$/)
{
$errorcnt++;
print STDERR "SANITY ERROR: '$target' has the dso_scheme [$idx_dso_scheme] values\n";
print STDERR " in the previous field\n";
}
- elsif ($fields[$idx_dso_scheme+1] =~ /^(beos|dl|dlfcn|win32|vms)$/)
+ elsif ($fields[$idx_dso_scheme+1] =~ /^(beos|dl|dlfcn|win32|win64|vms)$/)
{
$errorcnt++;
print STDERR "SANITY ERROR: '$target' has the dso_scheme [$idx_dso_scheme] values\n";
print STDERR " in the following field\n";
}
- elsif ($fields[$idx_dso_scheme] !~ /^(beos|dl|dlfcn|win32|vms|)$/)
+ elsif ($fields[$idx_dso_scheme] !~ /^(beos|dl|dlfcn|win32|win64|vms|)$/)
{
$errorcnt++;
print STDERR "SANITY ERROR: '$target' has the dso_scheme [$idx_dso_scheme] field = ",$fields[$idx_dso_scheme],"\n";
- print STDERR " valid values are 'beos', 'dl', 'dlfcn', 'win32' and 'vms'\n";
+ print STDERR " valid values are 'beos', 'dl', 'dlfcn', 'win32', 'win64', and 'vms'\n";
}
}
print STDERR "No sanity errors detected!\n" if $errorcnt == 0;
--- ms/do_ms.bat Mon Jan 19 14:26:32 1970
+++ ms/do_ms.bat Mon Jan 19 14:26:32 1970
@@ -1,7 +1,9 @@

perl util\mkfiles.pl >MINFO
perl util\mk1mf.pl no-asm VC-WIN32 >ms\nt.mak
+perl util\mk1mf.pl no-asm debug VC-WIN32 >ms\ntdebug.mak
perl util\mk1mf.pl dll no-asm VC-WIN32 >ms\ntdll.mak
+perl util\mk1mf.pl dll no-asm debug VC-WIN32 >ms\ntdlldebug.mak
if x%OSVERSION% == x goto skipce
perl util\mk1mf.pl no-asm VC-CE >ms\ce.mak
perl util\mk1mf.pl dll no-asm VC-CE >ms\cedll.mak
--- ms/do_nasm.bat Mon Jan 19 14:26:32 1970
+++ ms/do_nasm.bat Mon Jan 19 14:26:32 1970
@@ -1,7 +1,9 @@

perl util\mkfiles.pl >MINFO
perl util\mk1mf.pl nasm VC-WIN32 >ms\nt.mak
+perl util\mk1mf.pl nasm debug VC-WIN32 >ms\ntdebug.mak
perl util\mk1mf.pl dll nasm VC-WIN32 >ms\ntdll.mak
+perl util\mk1mf.pl dll nasm debug VC-WIN32 >ms\ntdlldebug.mak
perl util\mk1mf.pl nasm BC-NT >ms\bcb.mak

perl util\mkdef.pl 32 libeay > ms\libeay32.def
--- ms/do_win64a.bat Mon Jan 19 14:26:32 1970
+++ ms/do_win64a.bat Mon Jan 19 14:26:32 1970
@@ -13,7 +13,9 @@

:proceed
perl util\mk1mf.pl VC-WIN64A >ms\nt.mak
+perl util\mk1mf.pl debug VC-WIN64A >ms\ntdebug.mak
perl util\mk1mf.pl dll VC-WIN64A >ms\ntdll.mak
+perl util\mk1mf.pl dll debug VC-WIN64A >ms\ntdlldebug.mak

-perl util\mkdef.pl 32 libeay > ms\libeay32.def
-perl util\mkdef.pl 32 ssleay > ms\ssleay32.def
+perl util\mkdef.pl 64 libeay > ms\libeay64.def
+perl util\mkdef.pl 64 ssleay > ms\ssleay64.def
--- util/mk1mf.pl Mon Jan 19 14:26:32 1970
+++ util/mk1mf.pl Mon Jan 19 14:26:32 1970
@@ -178,6 +178,12 @@

$NT=0;

+$configuniqueundefinedtag="undefined";
+$confpreprocessorundefinedcondif="#if !defined(OPENSSL_UNIQUE_CONFIG)";
+# these values are to be overridden by specific patform .pl file
+$configuniquetag=$configuniqueundefinedtag;
+$confpreprocessorcondif=$confpreprocessorundefinedcondif;
+
push(@INC,"util/pl","pl");

if ($platform eq "auto" || $platform eq 'copy') {
@@ -242,6 +248,7 @@
$cflags.=' -DTERMIO';
}

+
$fipsdir =~ s/\//${o}/g;

$out_dir=(defined($VARS{'OUT'}))?$VARS{'OUT'}:$out_def.($debug?".dbg":"");
@@ -444,6 +451,14 @@
$ex_l_libs .= " \$(O_FIPSCANISTER)";
}
}
+
+if ($installpdb)
+ {
+ $extra_install .= <<"EOF";
+ \$(CP) \"\$(TMP_D)${o}*.pdb\" \"\$(INSTALLTOP)${o}lib\"
+EOF
+ }
+

$defs= <<"EOF";
# N.B. You MUST use -j on FreeBSD.
@@ -607,6 +622,8 @@
\$(MKDIR) \"\$(INSTALLTOP)${o}include${o}openssl\"
\$(MKDIR) \"\$(INSTALLTOP)${o}lib\"
\$(CP) \"\$(INCO_D)${o}*.\[ch\]\" \"\$(INSTALLTOP)${o}include${o}openssl\"
+ \$(CP) \"\$(INSTALLTOP)${o}include${o}openssl${o}opensslconf.h\" \"\$(INSTALLTOP)${o}include${o}openssl${o}opensslconf.${configuniquetag}.h\"
+ \$(CP) \"crypto${o}opensslconf.common.h\" \"\$(INSTALLTOP)${o}include${o}openssl${o}opensslconf.h\"
\$(CP) \"\$(BIN_D)$o\$(E_EXE)$exep \$(INSTALLTOP)${o}bin\"
\$(MKDIR) \"\$(OPENSSLDIR)\"
\$(CP) apps${o}openssl.cnf \"\$(OPENSSLDIR)\"
@@ -824,6 +841,67 @@
}
print "###################################################################\n";
print $rules;
+
+###
+# Create a common multi-platform opensslconf.common.h file that will become
+# opensslconf.h as part of the make install process. This relies on
+# the variables $configuniquetag and $confpreprocessorcondif being configured
+# by the lower level platform pl file.
+
+unlink("crypto/opensslconf.common.bak") || die "unable to remove old crypto/opensslconf.common.bak:$!\n" if ((-e "crypto/opensslconf.common.bak") && (-e "crypto/opensslconf.common.h"));
+rename("crypto/opensslconf.common.h","crypto/opensslconf.common.bak") || die "unable to rename crypto/opensslconf.common.h\n" if -e "crypto/opensslconf.common.h";
+
+open(OUT,'>crypto/opensslconf.common.h') || die "unable to create crypto/opensslconf.common.h:$!\n";
+print OUT "/* opensslconf.h - multi-platform conf file to include specific platform conf files */\n";
+print OUT "/* WARNING: Generated automatically by mk1mf.pl as opensslconf.common.h */\n\n";
+print OUT "#undef OPENSSL_UNIQUE_CONFIG\n\n";
+
+if (-e "crypto/opensslconf.common.bak") {
+ my $sectionhdr="//-- SECTION ";
+ my $insection=0;
+ my $skipsec=0;
+
+ open(IN,'<crypto/opensslconf.common.bak') || die "unable to read crypto/crypto/opensslconf.common.bak:$!\n";
+ while (my $line = <IN>)
+ {
+ if ($line =~ /^$sectionhdr/) {
+ $insection=1;
+ if (($line =~ /${configuniquetag}$/) || ($line =~ /${configuniqueundefinedtag}$/)) {
+ $skipsec=1;
+ }
+ else {
+ $skipsec=0;
+ }
+ }
+
+ if ($insection && !$skipsec) {
+ print OUT $line;
+ }
+ }
+ close(IN);
+}
+
+print OUT "//-- SECTION ${configuniquetag}\n";
+print OUT $confpreprocessorcondif."\n";
+print OUT " #define OPENSSL_UNIQUE_CONFIG ${configuniquetag}\n";
+print OUT " #include \"opensslconf.${configuniquetag}.h\"\n";
+print OUT "#endif\n";
+print OUT "\n";
+
+# undefined has to be last
+if ($configuniquetag ne $configuniqueundefinedtag) {
+ print OUT "//-- SECTION ${configuniqueundefinedtag}\n";
+ print OUT $confpreprocessorundefinedcondif."\n";
+ print OUT " #define OPENSSL_UNIQUE_CONFIG ${configuniqueundefinedtag}\n";
+ print OUT " #include \"opensslconf.${configuniqueundefinedtag}.h\"\n";
+ print OUT "#endif\n";
+ print OUT "\n";
+}
+
+close(OUT);
+
+###
+

###############################################
# strip off any trailing .[och] and append the relative directory
--- util/mkdef.pl Mon Jan 19 14:26:32 1970
+++ util/mkdef.pl Mon Jan 19 14:26:32 1970
@@ -71,6 +71,7 @@
my $VMSVAX=0;
my $VMSNonVAX=0;
my $VMS=0;
+my $W64=0;
my $W32=0;
my $W16=0;
my $NT=0;
@@ -80,7 +81,7 @@

my @known_platforms = ( "__FreeBSD__", "PERL5", "NeXT",
"EXPORT_VAR_AS_FUNCTION", "ZLIB", "OPENSSL_FIPS" );
-my @known_ossl_platforms = ( "VMS", "WIN16", "WIN32", "WINNT", "OS2" );
+my @known_ossl_platforms = ( "VMS", "WIN16", "WIN32", "WIN64", "WINNT", "OS2" );
my @known_algorithms = ( "RC2", "RC4", "RC5", "IDEA", "DES", "BF",
"CAST", "MD2", "MD4", "MD5", "SHA", "SHA0", "SHA1",
"SHA256", "SHA512", "RIPEMD",
@@ -157,6 +158,7 @@
foreach (@ARGV, split(/ /, $options))
{
$debug=1 if $_ eq "debug";
+ $W64=1 if $_ eq "64";
$W32=1 if $_ eq "32";
$W16=1 if $_ eq "16";
if($_ eq "NT") {
@@ -264,7 +266,7 @@
}

# If no platform is given, assume WIN32
-if ($W32 + $W16 + $VMS + $OS2 == 0) {
+if ($W64 + $W32 + $W16 + $VMS + $OS2 == 0) {
$W32 = 1;
}

@@ -275,7 +277,7 @@

if (!$do_ssl && !$do_crypto)
{
- print STDERR "usage: $0 ( ssl | crypto ) [ 16 | 32 | NT | OS2 ]\n";
+ print STDERR "usage: $0 ( ssl | crypto ) [ 16 | 32 | 64 | NT | OS2 ]\n";
exit(1);
}

@@ -1001,7 +1003,7 @@
# Prune the returned symbols

delete $syms{"bn_dump1"};
- $platform{"BIO_s_log"} .= ",!WIN32,!WIN16,!macintosh";
+ $platform{"BIO_s_log"} .= ",!WIN64,!WIN32,!WIN16,!macintosh";

$platform{"PEM_read_NS_CERT_SEQ"} = "VMS";
$platform{"PEM_write_NS_CERT_SEQ"} = "VMS";
@@ -1153,6 +1155,7 @@
if ($keyword eq "VMSVAX" && $VMSVAX) { return 1; }
if ($keyword eq "VMSNonVAX" && $VMSNonVAX) { return 1; }
if ($keyword eq "VMS" && $VMS) { return 1; }
+ if ($keyword eq "WIN64" && $W64) { return 1; }
if ($keyword eq "WIN32" && $W32) { return 1; }
if ($keyword eq "WIN16" && $W16) { return 1; }
if ($keyword eq "WINNT" && $NT) { return 1; }
@@ -1161,7 +1164,7 @@
# EXPORT_VAR_AS_FUNCTION means that global variables
# will be represented as functions. This currently
# only happens on VMS-VAX.
- if ($keyword eq "EXPORT_VAR_AS_FUNCTION" && ($VMSVAX || $W32 || $W16)) {
+ if ($keyword eq "EXPORT_VAR_AS_FUNCTION" && ($VMSVAX || $W64 || $W32 || $W16)) {
return 1;
}
if ($keyword eq "OPENSSL_FIPS" && $fips) {
@@ -1304,7 +1307,9 @@
my $what = "OpenSSL: implementation of Secure Socket Layer";
my $description = "$what $version, $name - http://$http_vendor";

- if ($W32)
+ if ($W64)
+ { $libname.="64"; }
+ elsif ($W32)
{ $libname.="32"; }
elsif ($W16)
{ $libname.="16"; }
@@ -1372,9 +1377,9 @@
}
$prev = $s2; # To warn about duplicates...
if($v && !$OS2) {
- printf OUT " %s%-39s @%-8d DATA\n",($W32)?"":"_",$s2,$n;
+ printf OUT " %s%-39s @%-8d DATA\n",($W32||$W64)?"":"_",$s2,$n;
} else {
- printf OUT " %s%-39s @%d\n",($W32||$OS2)?"":"_",$s2,$n;
+ printf OUT " %s%-39s @%d\n",($W32||$W64||$OS2)?"":"_",$s2,$n;
}
}
}
--- util/pl/linux.pl Mon Jan 19 14:26:32 1970
+++ util/pl/linux.pl Mon Jan 19 14:26:32 1970
@@ -7,6 +7,9 @@
$cp='/bin/cp';
$rm='/bin/rm -f';

+$configuniquetag="linux";
+$confpreprocessorcondif="#if defined(__linux__) || defined(linux)";
+
# C compiler stuff

$cc='gcc';
--- util/pl/VC-32.pl Mon Jan 19 14:26:32 1970
+++ util/pl/VC-32.pl Mon Jan 19 14:26:32 1970
@@ -3,19 +3,6 @@
# Win64 and WinCE [follow $FLAVOR variable to trace the differences].
#

-$ssl= "ssleay32";
-$crypto="libeay32";
-
-if ($fips && !$shlib)
- {
- $crypto="libeayfips32";
- $crypto_compat = "libeaycompat32.lib";
- }
-else
- {
- $crypto="libeay32";
- }
-
$o='\\';
$cp='$(PERL) util/copy.pl';
$mkdir='$(PERL) util/mkdir-p.pl';
@@ -44,6 +31,11 @@
# per 0.9.8 release remaining warnings were explicitly examined and
# considered safe to ignore.
#
+
+ $suffix="64";
+ $configuniquetag="win64";
+ $confpreprocessorcondif="#if defined(_WIN64)";
+
$base_cflags= " $mf_cflag";
my $f = $shlib || $fips ?' /MD':' /MT';
$opt_cflags=$f.' /Ox';
@@ -68,6 +60,11 @@
}
elsif ($FLAVOR =~ /CE/)
{
+
+ $suffix="ce32";
+ $configuniquetag="ce32";
+ $confpreprocessorcondif="#if defined(_WIN32_WCE)";
+
# sanity check
die '%OSVERSION% is not defined' if (!defined($ENV{'OSVERSION'}));
die '%PLATFORM% is not defined' if (!defined($ENV{'PLATFORM'}));
@@ -129,6 +126,10 @@
}
else # Win32
{
+ $suffix="32";
+ $configuniquetag="win32";
+ $confpreprocessorcondif="#if defined(_WIN32) && !defined(_WIN64)";
+
$base_cflags= " $mf_cflag";
my $f = $shlib || $fips ?' /MD':' /MT';
$ff = "/fixed";
@@ -136,27 +137,49 @@
$dbg_cflags=$f.'d /Od -DDEBUG -D_DEBUG';
$lflags="/nologo /subsystem:console /opt:ref";
}
+
+$ssl= "ssleay".$suffix; $ssl.="dll" if ($shlib); $ssl.="dbg" if ($debug);
+$crypto="libeay".$suffix; $crypto.="dll" if ($shlib); $crypto.="dbg" if ($debug);
+
+if ($fips && !$shlib)
+ {
+ $crypto="libeayfips".$suffix; $crypto.="dbg" if ($debug);
+ $crypto_compat = "libeaycompat".$suffix; $crypto_compat.="dbg" if ($debug); $crypto_compat.=".lib";
+ }
+
+
$lib_cflag='/Zl' if (!$shlib); # remove /DEFAULTLIBs from static lib
$mlflags='';

-$out_def ="out32"; $out_def.="dll" if ($shlib);
+$out_def ="out".$suffix; $out_def.="dll" if ($shlib); $out_def.="dbg" if ($debug);
$out_def.='_$(TARGETCPU)' if ($FLAVOR =~ /CE/);
-$tmp_def ="tmp32"; $tmp_def.="dll" if ($shlib);
+$tmp_def ="tmp".$suffix; $tmp_def.="dll" if ($shlib); $tmp_def.="dbg" if ($debug);
$tmp_def.='_$(TARGETCPU)' if ($FLAVOR =~ /CE/);
-$inc_def="inc32";
+$inc_def="inc".$suffix;
+
+# generate .pdb
+$installpdb=1;
+$app_cflag.=" /Zi";
+$lib_cflag.=" /Zi";

if ($debug)
{
$cflags=$dbg_cflags.$base_cflags;
+
+ if ($FLAVOR !~ /WIN64/)
+ {
+ $app_cflag.=" /ZI";
+ $lib_cflag.=" /ZI";
+ }
+
}
else
{
$cflags=$opt_cflags.$base_cflags;
}

-# generate symbols.pdb unconditionally
-$app_cflag.=" /Zi /Fd\$(TMP_D)/app";
-$lib_cflag.=" /Zi /Fd\$(TMP_D)/lib";
+$lib_cflag.= " /Fd\$(TMP_D)/lib".$suffix; $lib_cflag.="dll" if ($shlib); $lib_cflag.="dbg" if ($debug);
+$app_cflag.= " /Fd\$(TMP_D)/app".$suffix; $app_cflag.="dll" if ($shlib); $app_cflag.="dbg" if ($debug);
$lflags.=" /debug";

$obj='.obj';

Also for myself I setup a couple batch files for the configuration so I don't forget the prefix.

perl Configure VC-WIN32 --prefix=d:\lib\openssl

and

perl Configure VC-WIN64A --prefix=d:\lib\openssl

Also, for debug versions, instead of configure with debug-xxx you just use the two configs above and the patched do_win64a.bat and do_ms.bat/do_nasm.bat will also create a ntdebug.mak and ntddldebug.mak so you can just run nmake -f ms\ntdebug.mak. There were some last minute changes to not use /ZI on x64 to get rid of the warning (hope i didn't break something).

How to build OpenSSL on Windows with Visual Studio 2017?

I've not used VS2017 but previous versions. I imagine it is much the same. Note the instructions below are for OpenSSL 1.1.0 or above. They do not work for OpenSSL 1.0.2. In brief the steps are:

  1. Install Perl (either ActiveState or Strawberry)

[EDIT, see my (kritzel_sw) comment below: I would strongly recommend to use Strawberry)]


  1. Install NASM

  2. Make sure both Perl and NASM are on your %PATH%

  3. Fire up a Visual Studio Developer Command Prompt with administrative privileges (make sure you use the 32-bit one if you are building 32-bit OpenSSL, or the 64-bit one if you are building 64-bit OpenSSL)

  4. From the root of the OpenSSL source directory enter perl Configure VC-WIN32, if you want 32-bit OpenSSL or perl Configure VC-WIN64A if you want 64-bit OpenSSL

  5. Enter nmake

  6. Enter nmake test

  7. Enter nmake install

[EDIT, unless you change the target directory in the configuration, nmake install needs administrator privileges. So the VC command prompt must be started as administrator for this final step]

If anything goes wrong at any stage, check the INSTALL file and the NOTES.WIN file.

How do I compile fips capable openssl on Windows x64?

Found it, it seems by default the "include" directory is filled with 0kb files for some reason, I overwrited with the 32 bit include (inc32) directory's contents in the FIPS folder to the "include" one, and it seems to have solved the issue.

build openssl on win64 fail

To build openssl on win64 it's easier to use their native Visual C++ 2015 Build Tools.Use VS native tools command is recommended,found detail in this answer.If the vcvar32.bat doesn't work,refer this answer to modify it.The .Net version reference is here.After all these I built openssl-1.0.2k on Win64/x64 finally.



Related Topics



Leave a reply



Submit