dllvisual-studio-2005linker

When to include .lib and when to include .dll or both


I got a .h file, two .lib files, a .dll file and a tiny test project from a hardware vendor to talk to their hardware.

Compiling and running their test project works just fine. Noteworthy: they don't use the .dll. I can throw the dll-directory and all of it's content away, everything works just fine.

To start things off I simply copied the communication parts of their code (connect, disconnect and send a command) into my project. This is actually all that you can do. I have included the .h file and pointed to the directory containing the .lib files. Just like in the tiny test project. It all compiles, but when I try to run the project complains that it is missing the .dll file.

Can anybody explain what is happening? How are libs and dlls supposed to work?

All of this is on windows, VS2005. I compared the .vcproj files and could not find any significant differences.


Solution

  • The test project is statically linked - the lib is included in the exe.

    Your project is dynamically linked - the dll is referenced and therefore needed at runtime.

    See this Stack Overflow question for more information.