What is the difference between "Include Directories" and "Additional Include Directories"

C++Visual Studio-2010Visual StudioCompilation

C++ Problem Overview


In configuration properties of my project, under the "VC++ directories" there is an entry for "Include Directories". But under "C/C++" option, there is another entry called "Additional Include Directories". Same thing happens with library directories.

What are the difference between these two entries?

enter image description here enter image description here

C++ Solutions


Solution 1 - C++

This is awkwardness that got introduced in VS2010. The VC++ Directories settings used to be located in Tools + Options, Projects and Solutions, VC++ Directories. Global settings that applied to every project that was built on the machine. It is still there but points out that you should now change it in your project settings. A side-effect of the build engine overhaul in VS2010, enabling building with msbuild. Removing the per-project settings would have been logical but that would break too many existing projects.

As such, it is probably best to treat the VC++ Directories settings as the machine default. It is automatically preset by the VS installer. Tinker with it only if you need an unusual directory search order, putting the custom locations last. Very unusual to do so.

It does work however. And it did get taken advantage of eventually. Empowering the Platform Toolset setting in VS2012 and up. Different compiler, different linker, different #include directories, different linker search path. Modified with just one setting, nice.

Solution 2 - C++

The Include Directories corresponds to the environment variable INCLUDE.

> Directory settings displayed in the window are the directories that > Visual Studio will search for include files referred to in your source > code files. Corresponds to environment variable INCLUDE.

While the Additional Include Directories are passed via a command line argument (i.e. the \I option).

Solution 3 - C++

#CONFIGURING INCLUDE PATHS#

###VC++ Directories: Include Directories###

  • this value is inherited from the INCLUDE Windows environment variable which is defined outside of Visual Studio
    • environment variables can be: global to the computer or have user level scope
    • The INCLUDE and LIB environment variables are created when the Microsoft Windows SDK is installed with Visual Studio.

###C/C++: Additional Include Directories###

  • is a project level setting... you will have to define this value for every project in your solution
  • this value can be persisted to source control

#ADDITIONAL NOTES#

###Which one should I use?###

The decision to use Include Directories or Additional Include Directories will depend on your organization's development process. In my opinion, it is more important:

  • that you are able to consistently and reliably re-create the development environment (think: handing off source code to another developer)
  • for developers within an organization use a consistent approach

###A Note About Macros###

  • The C++ project configuration macros (not to be confused with C++ pre-processor #define directive) inherit content from different sources. Macros like...
  • $(Include) inherit their values from Windows environment variables
  • $(OutDir) inherit their values from Visual Studio IDE

#REFERENCES#

  • [Environment Variables (general introduction)][1]
  • [How to set the path and environment variables in Windows][2]

[1]: https://en.wikipedia.org/wiki/Environment_variable#Windows "Environment Variables {general introduction}" [2]: http://www.computerhope.com/issues/ch000549.htm "How to set the path and environment variables in Windows"

Solution 4 - C++

https://stackoverflow.com/questions/21593/what-is-the-difference-between-include-filename-and-include-filename

"Include Directories" -> #include <header>

"Additional Include Directories" -> #include "header"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionArtiumView Question on Stackoverflow
Solution 1 - C++Hans PassantView Answer on Stackoverflow
Solution 2 - C++CodeNakedView Answer on Stackoverflow
Solution 3 - C++PressaccoView Answer on Stackoverflow
Solution 4 - C++ZhangView Answer on Stackoverflow