本文介绍了如何构建与 Windows 运行时静态链接的 OpenSSL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为使用 OpenSSL 1.0.1e 库的 Windows 开发 C++ 应用程序.我使用的是 Visual Studio 2008.

I'm working on a C++ application for Windows that uses OpenSSL 1.0.1e library. I'm on Visual Studio 2008.

出于可移植性的原因,我的应用程序静态链接到运行时库(/MT/MTd 选项).我的应用程序不附带运行时库.

For portability reasons my application is statically linked against runtime libraries (/MT and /MTd options). And I don't ship runtime libs with my application.

根据 OpenSSL 常见问题,该库默认链接到多线程 DLL 运行时(/MDd) 这显然与我的场景不兼容.因此,为了使我的程序正常工作,我已将 applink.c 添加到我的项目中.在我的开发机器和大多数测试计算机上,程序运行良好.

Per the OpenSSL FAQ, the library is by default linked against multithreaded DLL runtime (/MDd) which is obviously incompatible with my scenario. So to make my program work I've added applink.c to my project. On my dev machine and on most test computers the program works fine.

但不幸的是,我找到了无法启动应用程序的计算机.Windows 显示错误:

But unfortunately I've located computers where the app doesn't start. Windows displays error:

The application failed to initialize properly (0xc0150002). Click on OK to
terminate the application.

我已经在 Dependency Walker 中打开了 libeay32.dll,但我发现没有找到 MSVCR90.dll.所以 applink.c 的技巧对我来说真的不起作用.

I've opened libeay32.dll in Dependency Walker and I see that MSVCR90.dll is not found. So the trick with applink.c doesn't really work for me.

如何使用 /MT/MTd 选项构建 OpenSSL?

How do I build OpenSSL with /MT or /MTd option?

推荐答案

使用 nt.mak makefile 而不是 ntdll.mak makefile.

Use the nt.mak makefile rather than the ntdll.mak makefile.

顺便说一句,我已经围绕标准 OpenSSL 构建脚本编写了一些脚本,这使得在混合 x86 和 x64 的 Windows 上使用 OpenSSL 变得更容易"(至少对我而言),您可以从 此处.

As an aside, I have written some scripts around the standard OpenSSL build scripts which make it 'easier' (for me at least) to use OpenSSL on Windows with a mix of both x86 and x64, you can get them from here.

这篇关于如何构建与 Windows 运行时静态链接的 OpenSSL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-18 12:39
查看更多