In Visual Studio how to give relative path of a .lib file in project properties
-
02-07-2019 - |
Question
I am building a project using Visual Studio. The project has a dependency on a lib file generated by another project. This project is there is the parent directory of the actual project I am building.
To be more clear, I have a "ParentDir" which has two subDirectories Project1 and Project2 under it. Now Project1 depends on lib generated by Project2.
In the properties of Project1, I am trying to give a relative path using $(SolutionDir)/../ParentDir/Project2/Debug But this does not seem to work.
Can you tell me where i am going wrong, or suggest the correct way of achieving this.
Solution
Add the dependant project to your solution and set it as a dependency of the other project using project properties. Then it just magically works ;).
A solution is just a file that describes a set of related (interconnected) projects and the relation between them, so this is the correct way of doing it.
OTHER TIPS
Your current dir is your $(ProjectDir), that is where .vcproj file is.
So, just write ../Project2/Debug, that will do.
Even better, write ../Project2/$(ConfigurationName) for all configurations
thus you will be always linking to the correct version of that lib.
I think Visual Studio does not expand the relative path properly when the ".." is placed somewhere in the middle of the path string. It only knows how to expand ..{sub-path}.