views:

278

answers:

3

I am trying to build a DLL and it needs to reference a library namely libeay32.dll from the openssl package. I cant seem to add it as a reference under the Property Pages->Common Properties->Add New Reference because it gives error "Could not add a reference to file 'C:\OpenSSL\libeay32.dll' because it is neither a .NET assembly or registered Active X Control. I can compile and run it when I use the Linker->Input->Additional Dependencies and set the static lib 'C:\OpenSSL\lib\libeay32.lib'. But the end result is I need to include the libeay32.dll also. What am I doing wrong?

+4  A: 

You're doing everything correctly. "Add Reference" is for .NET assemblies (and COM components used via .NET COM interop). The second approach that you've tried is the correct way to do this for native code, but libeay32.lib is not a static library; it's an export library for the DLL.

Pavel Minaev
A: 

From openssl-0.9.8l.tar.gz\INSTALL.W32 "...You can also build a static version of the library using the Makefile ms\nt.mak ..."

This probably means that developers of SSL want you to follow their adoption routine i.e.

  • rebuild thing from source using whatever obscure Win32 platform dependencies were out there 7-10 years ago
  • for this: use nmake and masm
  • for this: install non the less Windows DDK! (as they require masm)
  • set couple of million build flags to target make to produce static portion of library
  • before you run make, you will need to have:
  • perl!
  • but wait, to run perl you probably will need Cygwin

Welcome to open source world. I'd rather never use open source alltogether

RocketSurgeon
+1  A: 

As Pavel metioned, libeay32.lib is not the full library that your application can be statically linked against and run. It's used to resolve reference to the dynamic lib, dll. So, your app still need the dll to run.

http://msdn.microsoft.com/en-us/library/f0z8kac4.aspx

Raymond
OK so what I was meaning to do is to build a DLL that does some encryption using functions from the OpenSSL package. But I want to make the build so the DLL can include(or merge?) the required libeay32.dll from openssl so the customer doesnt need to worry about having libeay32.dll already. Isnt there any simple way to do this or do I really need to rebuild the source for OpenSSL with my own project?
yhilbert
You can release libeay32.dll along with your dll. If you prefer to distribute the dll as a single file, you have to use static lib version of openssl. If it's not already provided, you need to rebuild it.The "Configuration Type" property of the project controls whether to build a dynamic or static library.
Raymond