How to find the Relative Path to other Common Folders – More Easily?

16 12 2008


Well you know what a relative path is. The “.\..\..\Folder” thing. Usually in project settings, while referring the path of other common include folders, relative path is being used. Because, it won’t break the project settings even though the entire development folder structure is moved from one location to another.

To be more specific, If you have specified absolute path like – “c:\Source\BlahBlahProject\Libs” in the project settings, if you move Source folder to D:\ your project won’t compile. Relative paths are good, but its a bit difficult to calculate it. I saw people calculating it with their memory by touching the folder structure in monitor. 😉 Some advanced guys uses the windows explorer’s auto complete feature to get the relative path. But is there any other easy method to get it?

relativepath


Well, You can use Visual Studio for it. Just follow the steps. Assume you want to get the relative path from your project folder to the common lib folder – “c:\Source\BlahBlahProject\Libs”.

1) Load you project in visual studio.
2) Create a file hello.cpp in folder – “c:\Source\BlahBlahProject\Libs”.
3) Add the file to your project by using menu – Project > Add To Project > Files.
4) Right click the file and take Properties.
relativepath1

5) In the properties, you can get the relative path from “Persist as” editbox.
relativepath2


The only limitation is our imagination. Isn’t it? 😉


Targeted Audience – Intermediate.


Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s




%d bloggers like this: