简体   繁体   English

如何在Windows上使用OpenSSL FIPS静态库构建DLL?

[英]How can I build a DLL using the OpenSSL FIPS static library on Windows?

I asked this on the openssl-users mailing list with no replies, so I thought I'd try here. 我在openssl-users邮件列表上询问了这个没有回复的内容,所以我想我会在这里试试。

I am trying to build a Windows DLL that includes the static OpenSSL FIPS libraries. 我正在尝试构建一个包含静态OpenSSL FIPS库的Windows DLL。 I built the FIPS libraries using perl Configure fips --with-fipslibdir=... -no-shared and then nmake -f ms\\nt.mak . 我使用perl Configure fips --with-fipslibdir=... -no-shared然后使用nmake -f ms\\nt.mak构建FIPS库。 I'm using openssl-fips-2.0.5, openssl-1.0.1j, and MS Visual Studio 2010. 我正在使用openssl-fips-2.0.5,openssl-1.0.1j和MS Visual Studio 2010。

Now I'm trying to link the resulting libraries into my DLL. 现在我正在尝试将生成的库链接到我的DLL中。 I've followed the instructions in the OpenSSL FIPS 2.0 User's Guide , setting a bunch of environment variables (FIPS_LINK, FIPS_CC, FIPS_CC_ARGS, etc.) and then called fipslink.pl . 我按照OpenSSL FIPS 2.0用户指南中的说明 ,设置了一堆环境变量(FIPS_LINK,FIPS_CC,FIPS_CC_ARGS等),然后调用了fipslink.pl But I'm getting a "First stage Link failure". 但我得到了“第一阶段链接失败”。

It reports "Integrity check OK" and then compiles fips_premain.c, but when linking the DLL I get a bunch of "locally defined symbol _time64 imported" warnings (as well as strncmp, _errno, abort, fprintf, and others), and then some unresolved external symbols including: 它报告“完整性检查OK”,然后编译fips_premain.c,但是当链接DLL时,我得到一堆“本地定义的符号_time64导入”警告(以及strncmp,_errno,abort,fprintf等),然后一些未解决的外部符号包括:

__imp_strncpy __imp_strncpy
__imp_qsort __imp_qsort
__imp_wcsstr __imp_wcsstr
__imp_vsnwprintf __imp_vsnwprintf

All of the errors come from libeayfips32.lib, libeaycompat32.lib, and ssleay32.lib. 所有错误都来自libeayfips32.lib,libeaycompat32.lib和ssleay32.lib。

I've played around with adding and removing things like /NODEFAULTLIB:msvcrt and /NODEFAULTLIB:libcmtd , and building with /MT or /MD or neither, but I keep getting linker errors each time. 我已经玩过添加和删除/NODEFAULTLIB:msvcrt/NODEFAULTLIB:libcmtd ,并使用/MT/MD构建,或者两者都没有,但我每次都会遇到链接器错误。 What am I missing? 我错过了什么?

open file ms\\nt.mak then modify line #28 by adding msvcrt.lib msvcrtd.lib at the end , to be like: 打开文件ms\\nt.mak然后通过在末尾添加msvcrt.lib msvcrtd.lib修改第28行,如:

EX_LIBS=ws2_32.lib gdi32.lib advapi32.lib crypt32.lib user32.lib msvcrt.lib msvcrtd.lib

then run : nmake -f ms\\nt.mak from visual studio command prompt.I hope that no linker messages will appear. 然后从visual studio命令提示符运行: nmake -f ms\\nt.mak 。我希望不会出现任何链接器消息。

Also try to build the DLL by nmake -f ms\\ntdll.mak 还尝试通过nmake -f ms\\ntdll.mak构建DLL

I speculate that the "-no-shared" switch to the Configure script statically links the C standard library. 我推测,配置脚本的“-no-shared”切换器静态链接C标准库。 You'd get your static OpenSSL FIPS library, but it would include implementations of printf and friends, as you actually experience. 您将获得静态OpenSSL FIPS库,但它将包括printf和friends的实现,就像您实际体验的那样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM