Setting header file paths in Visual Studio 2010

I was working on a project which required some coding in Visual Studio recently and ran into a problem: the included header files were not in the same directory as the source files and therefore were not found during a build. Not being familiar with the code, I was not very keen on going through and changing the #include “header.h” lines manually to the proper relative path (which would have been along the lines of #include “../../include/header.h” in some cases and different in others).

From my experience with other compilers I knew there had to be a way to specify the location where the VS2010 C++ compiler was to look for the header files. A bit of digging through Google didn’t help very much as the consensus was: relative paths are the way to go. Going through the project settings I finally came upon my fix which I will share with you.

To set the path:

  1. Go to your project’s properties. (Either Right-click the project name and select Properties or from the menu bar click Project –> Properties.)
  2. Navigate to Configuration Properties –> C/C++ –> General as shown below and enter the path in the Additional Include Directories box ( separate;entries;with;semicolons; )

Visual Studio project properties box

Voila! The header files are now found and the project compiles!