3
votes

I have built VTK in my computer with both dll and .lib files. When I want to create a project that uses VTK, I have to include the header files and link .lib files in project properties. In addition I have to add the .dll files in to the project path as well. I have several questions regarding this,

  1. What is the difference between .libs and .dll files?
  2. Is it possible to create a project with only using either .dll or .lib files. (I can link the .lib files and not add dlls to path or add dlls to path and not link .lib files)?

I would be grateful for any explanations. Thanks.

2
You have built VTK as a DLL project. The the DLL contains the executable code (and data) and the LIB just contains the address fix-ups for the exports from the DLL. Without the LIB you would need to manually load the DLL and fix-up your calls into it by hand.Richard Critten

2 Answers

9
votes
  1. .lib files are used by the linker to resolve imported items. .dll files contain code that is loaded dynamically at runtime.

  2. If you have a static library, it contains all the code needed and there is no .dll. If you have a .dll you also need the companion .lib for linking correctly.

4
votes

The .lib files are only used by the linker during compilation. Whereas .dll files are used by the compiled exe during execution. In other words, after you've compiled the program you shouldn't need the .lib files anymore. When packaging your software for distribution you will only need your .exe, the .dll's, and any resources that didn't get packaged into your exe.