包含 OpenSSL 作为静态库,但它仍在寻找 DLL?
我使用以下位置提供的安装程序在 Windows 上安装了 OpenSSL 1.0.0: http://www.slproweb.com/products/Win32OpenSSL.html
我添加了 . lib 文件添加到我的项目(这是 Visual Studio,将其添加到项目设置 -> 链接器 -> 输入),并且它可以编译并正常工作。但是当我删除 Windows\system32 中的 OpenSSL DLL 文件时,它会抱怨:
"Debugger:: An unhandled non-continuable STATUS_DLL_NOT_FOUND exception was thrown during process load"
知道为什么它仍然在寻找 DLL,即使它是使用静态库编译的?我没有在项目中的任何地方引用 DLL。我包含的静态库是 libeay32.lib 和 ssleay32.lib。
谢谢, -M
I installed OpenSSL 1.0.0 on Windows using the installer available at:
http://www.slproweb.com/products/Win32OpenSSL.html
I added the .lib files to my project (this is Visual Studio, added it to Project Settings->Linker->Input), and it compiles and works fine. But when I remove the OpenSSL DLL files in Windows\system32, it complains that
"Debugger:: An unhandled non-continuable STATUS_DLL_NOT_FOUND exception was thrown during process load"
Any idea why it's still looking for the DLL even when it's compiled with the static libs? I'm not referencing the DLLs anywhere in the project. The static libs I included are libeay32.lib and ssleay32.lib.
Thanks,
-M
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用大小接近 19 mb 的 libeay32MT.lib 文件作为您的库。因为它是一个静态库,但libeay32.lib是一个使用dll的库。
use libeay32MT.lib file that have almost 19 mb size as your library. because it is a static library but libeay32.lib is a library for using the dll.
它正在寻找 DLL,因为代码是在运行时动态加载的。静态库中的代码只是一组调用 DLL 的存根函数——比较 .lib 和 .dll 文件的大小,我敢打赌您会发现 DLL 要大得多,因为这就是大部分实际的加密代码都是谎言。
因此,正如您所发现的,您不应该删除这些 DLL。为了正确分发您的程序,您还需要随程序一起分发这些 DLL,以使其正常工作。但是,请记住,这样做会存在法律问题,因为美国对某些加密代码有出口限制。 因此,在重新分发这些 DLL 时要格外小心——特别确保您所做的事情是合法的。
It's looking for the DLLs because the code is loaded dynamically at runtime. The code in the static libraries is just a set of stub functions which call into the DLL -- compare the sizes of the .lib and .dll files, and I bet you'll see that the DLLs are much larger, since that's where the bulk of the actual encryption code lies.
Hence, as you found out, you should not delete the DLLs. In order to distribute your program properly, you'll also need to distribute those DLLs with it in order for it to work correctly. However, keep in mind that there are legal issues with doing this, since there are US export restrictions on certain encryption code. So be extra careful in redistributing those DLLs -- make extra sure what you're doing is legal.
您可以在这里获取静态库:
http://www.ie7pro.com/openssl/ openssl-0.9.8g_static_win32.zip
(请参阅http://www.ie7pro.com/openssl。 html)。
这些是使用静态运行时库构建的,因此如果您使用 VC++,您可能需要转到:
配置属性 --> C/C++-->代码生成-->运行时库
并选择 /MT 而不是 /MD 以避免链接冲突(或者在链接器 --> 命令行 --> 其他选项中使用 /NODEFAULTLIB:LIBCMT 等)。
You can get static libraries here:
http://www.ie7pro.com/openssl/openssl-0.9.8g_static_win32.zip
(see http://www.ie7pro.com/openssl.html).
These are built with static runtime libraries so if you are using VC++ you may need to go to:
Configuration Properties--> C/C++--> Code Generation--> Runtime Library
and select /MT instead of /MD to avoid linkage conflicts (or alternatively use the /NODEFAULTLIB:LIBCMT, etc. in Linker--> Command Line--> Additional Options).