How to define relative paths in Visual Studio Project?

Ali Ahmed picture Ali Ahmed · Aug 1, 2011 · Viewed 178.5k times · Source

I have a library and a console application that uses a library. The library has a folder with source and header files.

My project is in a child/inner directory but that library directory that I want to include is in a parent/upper directory.

My project directory:

H:\Gmail_04\gsasl-1.0\lib\libgsaslMain

Includes files are here:

H:\Gmail_04\gsasl-1.0\src

How can I use paths relative to the project directory, to include folders that are in a parent/upper directory?

Answer

eckes picture eckes · Aug 1, 2011

Instead of using relative paths, you could also use the predefined macros of VS to achieve this.

$(ProjectDir) points to the directory of your .vcproj file, $(SolutionDir) is the directory of the .sln file.

You get a list of available macros when opening a project, go to
Properties → Configuration Properties → C/C++ → General
and hit the three dots:

project properties

In the upcoming dialog, hit Macros to see the macros that are predefined by the Studio (consult MSDN for their meaning):

additional include directories

You can use the Macros by typing $(MACRO_NAME) (note the $ and the round brackets).