Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define relative paths in Visual Studio Project?

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?

like image 253
Ali Ahmed Avatar asked Aug 01 '11 07:08

Ali Ahmed


People also ask

How do you set a relative path in Visual Studio code?

Relative Path Extension for VS CodePress Ctrl+Shift+H (Mac: Cmd+Shift+H ) and start typing the file you want.

How do you specify relative paths?

Relative paths make use of two special symbols, a dot (.) and a double-dot (..), which translate into the current directory and the parent directory. Double dots are used for moving up in the hierarchy. A single dot represents the current directory itself.

How do I use reference path in Visual Studio?

If you're using Visual Basic, select the References page, and then click the Reference Paths button. In the Reference Paths dialog box, type the path of the folder that contains the item you want to reference in the Folder field, and then click the Add Folder button.

How do I find the path to a folder in Visual Studio?

Did you know you can right click on the tab in the code editor window to access the file path or to open the folder in Windows Explorer? Check it out. By default, the file path for Visual Studio projects is very long.


1 Answers

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).

like image 164
eckes Avatar answered Oct 02 '22 08:10

eckes