Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use the Visual Studio Additional dependencies?

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?

like image 644
user205834 Avatar asked Nov 01 '10 03:11

user205834


People also ask

What is the difference between dependencies and references in Visual Studio?

They are basically no different, they are used to store and manage references. Just as Lex said, the Dependencies is a better way to represent different types of references, we can clearly know where the reference comes from, SDK, nuget, etc. so that we can manage our references more efficiently.

How do I add additional dependencies in Visual Studio?

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

What is project dependency in Visual Studio?

When a project consumes executable code generated by another project, the project that generates the code is referred to as a project dependency of the project that consumes the code. Such dependency relationships can be defined in the Project Dependencies dialog box.


2 Answers

  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.

like image 113
Jerry Coffin Avatar answered Oct 21 '22 03:10

Jerry Coffin


And just to point out the obvious, you don't have to add any .h files you are using in a properties setting of your project because you explicitly include them in your source code, which looks for the headers in the paths you have already provided.

like image 21
Claude Avatar answered Oct 21 '22 02:10

Claude