开发者

Included OpenSSL as a static library, but it's still looking for a DLL?

开发者 https://www.devze.com 2023-01-23 15:25 出处:网络
I installed OpenSSL 1.0.0 on W开发者_如何学Cindows using the installer available at: http://www.slproweb.com/products/Win32OpenSSL.html

I installed OpenSSL 1.0.0 on W开发者_如何学Cindows 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


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.


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.


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消