When to use the Visual Studio Additional dependencies?

user205834 picture user205834 · Nov 1, 2010 · Viewed 49.5k times · Source

In C++, you got the header files (.h), the (.lib) files and the (.dll) files.

In Visual Studio, you provide the location to search for these files in three different places:

  1. Configuration Properties => C/C++ => General => Additional Include directories. Here you list out the "include" directories that you want searched and made available.

  2. Configuration Properties => Linker => General => Additional Library directories. Here you list out the "lib" directories that you want to be searched and made available.

  3. Configuration Properties => Linker => Input => Additional dependencies. Here you explicitly specify the .lib files that want to include.

The questions are:

Q1: If you have specified the header file in #1 and the lib in #2, why/when would you want to specify anything in #3?

Q2: I see people including a specific debug or release version of a lib in #3. Can you specify either the debug or the release version of a lib in #3 and still build in release or debug mode? Ideally, which version of the library debug/release should be provided here?

Answer

Jerry Coffin picture Jerry Coffin · Nov 1, 2010
  1. Configuration Properties => C/C++ => General => Additional Include directories. Here you list out the "include" directories that you want searched and made available.

This tells the compiler where to look for header files enclosed in angle brackets. This affects how the compiler (or preprocessor) does it's job.

  1. Configuration Properties => Linker => General => Additional Library directories. Here you list out the "lib" directories that you want to be searched and made available.

This tells the linker where to look for libraries (i.e., what directories to look in). This affects how the linker (rather than the compiler) does its job.

  1. Configuration Properties => Linker => Input => Additional dependencies. Here you explicitly specify the .lib files that want to include.

This tells the linker what libraries to look for in those directories. This also affects how the linker does its job.

Q1: Generally if you use 2, you almost certainly need to use 3 as well. 3 tells it what library to link with, and 2 tells it where to find that library. Of course, it can be more than one library as well.

Q2: If a debug and release library are both provided, you typically want to use the debug version in a debug build and the release version in the release build. At the top-left corner of the dialog you select which configuration you want to modify. Typically you'll want to specify directories for both debug and release, but specify individual libraries, one for debug and one for release.