Search code examples
visual-c++dllstatic-libraries

DLL needs LIB, but looking for DLL


In my source I have:

    #pragma comment(lib, "ldv32.lib")

Originally this was:

    #pragma comment(lib, "ldv32")

When I build and then try to register the DLL it fails:

Output from regsvr32

I used "Dependency Walker" to look at the DLL and I could see that it was trying to open LDV32.DLL, so I then edited the project and modified the pragma. Cleaned and Rebuilt project, however it still fails and "Dependency Walker" still reports that the DLL is looking for LDV32.DLL

How do I fix this, I've checked the path and project build, the location of the LIB is specified but why is it looking for a DLL and not the LIB?


Solution

  • The library ldv32.lib is an import library. It resolves the externals that are used in your DLL module. But it implements only small stubs. When the module is loaded with LoadLibrary, some code in the the ldv32.lib tries to load the DLL ldv32.dll that implements the actual functionality.

    You should lookup the Echolon OpenLDV DLL "ldv32.dll" and copy it in the folder where the process is loaded from. If you share your program or DLL make sure to include that DLL.

    You can also check if a static LIB exists. In that case you can link with that.