C++ .lib when developing, .dll when running application

74 Views Asked by At

I am using a company internal SDK. When installed, it provides a .lib file (xyz.lib for example) in both 32b/64b as well as two header files. When I create an application that utilizes the SDK I can build it, but when I try to run it, the application errors out saying it is looking for xyz.dll. Is the SDK supposed to include this DLL? Can I generate a .dll from the .lib file? From my research, it seems to be the other way around. Any thoughts?

1

There are 1 best solutions below

2
On

A DLL can be loaded in two ways, explicitly or implicitly.

Explicit DLL loading involves calling LoadLibrary and then calling GetProcAddress to get the address of an exported function you want to call.

Implicit DLL loading is done at compile time by linking in a lib file that contains the definition of the exported functions. This adds a dependency to your DLL that will load the correct DLL at runtime.

Implicitly linked DLLs use the Dynamic-Link Library Search Order to determine where to load the DLL from. It will load the first instance of the DLL it finds searching the locations noted in the order.

If you're linking against the lib file but the DLL can't be found, that means it isn't present anywhere in the search path.

Take the compiled DLL and stick it somewhere in that path. Usually the working directory of the application is fine.