如何编译OpenSSL for x64?

问题描述:

按照INSTALL.W64的说明之后,我有两个问题:如何编译OpenSSL for x64?

  • 的代码仍然写到“out32”文件夹中。我需要能够链接到我的工作站上的库的32位和64位版本,所以我不希望64位版本打开32位库。
  • 输出仍然是32位!这意味着当尝试从x64应用程序链接到库时,会出现“未解析的外部符号”错误。

编译静态库(发布和调试),这是你需要做的:

  1. 安装Perl - www.activestate.com
  2. 运行“Visual Studio 2008中的x64跨工具命令提示符“(注:常规命令提示将无法正常工作。)
  3. 配置与 perl的配置VC-WIN64A没有共享无想法
  4. 运行:MS \ do_win64a
  5. EDIT毫秒在输出显示目录\ nt.mak和改变 “32” 到 “64”:
 
    # The output directory for everything intersting 
    OUT_D=out64.dbg 
    # The output directory for all the temporary muck 
    TMP_D=tmp64.dbg 
    # The output directory for the header files 
    INC_D=inc64 
    INCO_D=inc64\openssl 
  1. EDIT MS \ nt.mak和除去bufferoverflowu。如果您收到关于它的错误,请从EX_LIBS获取lib。
  2. 运行:NMAKE -f MS \ nt.mak
  3. 编辑MS \ do_win64a文件,并添加 “调试” 的所有线路,除 “ml64” 和最后两行
  4. 运行:MS \ do_win64a
  5. 重复步骤4和5
  6. 将ms \ nt.mak文件和ADD/Zi编辑到CFLAG列表中!
  7. 运行:NMAKE -f MS \ nt.mak
开始=>
+0

看来,输出仍然命名为'* 32.lib`(`libeay32.dll`和`ssleay32.dll `)。名称是否有误或我没有正确地遵循这些说明? – 2012-06-15 15:30:00

您还可以使用MSYS + mingw-w64

1)下载并解压MSYS到C:\ MSYS
2)下载并解压mingw- w64到c:\ mingw64
3)运行msys postinstall脚本。当它要求你的mingw安装时,将它指向C:\ mingw64 \ bin
4)提取一个openssl每日快照(1.0.0版本有一个bug)。在源代码目录运行 配置mingw64
使
化妆检查
使安装
5)OpenSSL是安装到/本地/

如果你正在构建中的cygwin,可以使用下面的脚本,假设MSDEVPATH已经设置到Visual Studio目录

echo "Building x64 OpenSSL" 
# save the path of the x86 msdev 
MSDEVPATH_x86=$MSDEVPATH 
# and set a new var with x64 one 
MSDEVPATH_x64=`cygpath -u $MSDEVPATH/bin/x86_amd64` 

# now set vars with the several lib path for x64 in windows mode 
LIBPATH_AMD64=`cygpath -w $MSDEVPATH_x86/lib/amd64` 
LIBPATH_PLATFORM_x64=`cygpath -w $MSDEVPATH_x86/PlatformSDK/lib/x64` 
# and set the LIB env var that link looks at 
export LIB="$LIBPATH_AMD64;$LIBPATH_PLATFORM_x64" 

# the new path for nmake to look for cl, x64 at the start to override any other msdev that was set previously 
export PATH=$MSDEVPATH_x64:$PATH 

./Configure VC-WIN64A zlib-dynamic --prefix=$OUT --with-zlib-include=zlib-$ZLIB_VERSION/include --with-zlib-lib=zlib-$ZLIB_VERSION/x64_lib 

# do the deed 
ms/do_win64a.bat 
$MSDEVPATH_x86/bin/nmake -f ms/ntdll.mak ${1:-install} 

我这种方式解决了这个问题,使用1.0.1c来源:

将此块添加到util/pl/VC-32.pl,在$o='\\';之前。

if ($debug) 
    { 
    $ssl .= 'd'; 
    $crypto .= 'd'; 
    } 

只是if ($debug)前行此块添加到util/pl/VC-32.pl

if ($FLAVOR =~ /WIN64/) 
    { 
    $out_def =~ s/32/64/; 
    $tmp_def =~ s/32/64/; 
    $inc_def =~ s/32/64/; 
    } 

然后建立各品种:

setenv /x86 /release 
perl Configure VC-WIN32 --prefix=build -DUNICODE -D_UNICODE 
ms\do_ms 
nmake -f ms\ntdll.mak 

setenv /x64 /release 
perl Configure VC-WIN64A --prefix=build 
ms\do_win64a.bat 
nmake -f ms\ntdll.mak 

setenv /x86 /debug 
perl Configure debug-VC-WIN32 --prefix=build -DUNICODE -D_UNICODE 
ms\do_ms 
move /y ms\libeay32.def ms\libeay32d.def 
move /y ms\ssleay32.def ms\ssleay32d.def 
nmake -f ms\ntdll.mak 

setenv /x64 /debug 
perl Configure debug-VC-WIN64A --prefix=build 
ms\do_win64a.bat 
move /y ms\libeay32.def ms\libeay32d.def 
move /y ms\ssleay32.def ms\ssleay32d.def 
nmake -f ms\ntdll.mak 

根据官方文档:

“你可能会惊讶:64位文物确实在out32输出*子目录和熊名字结尾* 32.dll。事实上,64位编译目标是对传统32位Windows目标的增量更改。许多编译标记仍然标记为“32”,尽管这些标记适用于32位和64位目标。

所以第一个答案不再需要。

说明可以在这里找到:

https://wiki.openssl.org/index.php/Compilation_and_Installation#W64

使用Conan。安装和使用非常简单。

您可以请求文件准备好使用。例如用于Linux的x64或使用与Visual Studio 2012在此样本指令:

conan install OpenSSL/[email protected]/stable -s arch="x86_64" -s build_type="Debug" -s compiler="gcc" -s compiler.version="5.3" -s os="Linux" -o 386="False" -o no_asm="False" -o no_rsa="False" -o no_cast="False" -o no_hmac="False" -o no_sse2="False" -o no_zlib="False" ...