Generalize Include Path - visual-studio-2010

I am using Microsoft Visual Studios 2010, and I have found out how to set new include paths. Now I want to make it so that other users can utilize my project. If my current path is C:\Users\jsestrad\Documents\Homework\EE350\Lab\power, for example, is there a way I can start making it search from ..\Homework\EE350\Lab\power so that other users can utilize the include path?

You can use MSBuild properties in the path, including $(ProjectDir), which is the directory in which the project is located, and $(SolutionDir), which is the directory in which the solution is located.
The simplest thing to do would be to ensure that everyone has the include files in the same location relative to the project, then set the include path relative to $(ProjectDir).
For example, if your project is in C:\Users\jsestrad\Documents\Homework\EE350\Lab and your includes are in C:\Users\jsestrad\Documents\Homework\Stuff, you could add $(ProjectDir)..\Stuff to your include path.

Related

Search Paths Confusion in Xcode 4.6

In Xcode I added MailCore as a subproject, and target dependency. It works great on my machine. Sadly when I share the project with another collaborator, he's unable to get the header file to show up.
Somehow his search paths have my folder names hardcoded in (as in andrewjl), is there a way to fix this in order to point to an analogous directory on his machine?
Instead of using an absolute search path, use a relative one.
"$(SRCROOT)" is where your projectfile is located.
"$(SRCROOT)/AnotherFolder" for AnotherFolder is a peer of your project file
once add this variable, to the search path (after double tapping on the searchpaths line), you can add "$(SRCROOT)/Products/MyReceipt.........." and once you dismiss the add/remove searchPath popover, you'll see where the search path is pointing to.
Your search paths are absolute paths. Write them as relative paths (relative to the project).

Including directories in VC++ when working from multiple computers

In Visual Studio 2010, how to I set up my VC++ import directories so that I can build my project from multiple machines? For example, my project requires the use of a graphics library that's installed on both of the machines I'm using, but located on different paths.
I imagine the answer is some sort of macro, but I'm new to Visual Studio, so I'm not sure if my intuitions are correct.
I'm transitioning from the Matlab environment, where you can set the path directly per machine, rather than per project. Does Visual Studio have such functionality, or is everything at the level of project properties?
You can indeed use macros to set your include and lib directories on a per machine basis.
if you have your files in your project directory you can use:
$(SolutionDir)\ This will point to the full path of your solution directory root
$(ProjectDir)\ This will point to the full path of your project directory root.
You can place your graphics library in your project directory and point to it like:
$(ProjectDir)\graphicslib, for example, or any other place you want to put it in your solution.
More info is located here http://msdn.microsoft.com/en-us/library/c02as0cs.aspx
use a hierarchy of property sheets, or use a tool like CMake to generate project files for you (as it should automatically find all the libs/includes).
For the property sheets: add the same property sheet to each project. Withing that property sheet, include other property sheets with predefined names. Then on each computer you work, you will have to provide those 'per-machine' propert sheets. For example:
main.vsprops -> include by every project
|- matlab.vsprops -> sets the lib/includes for matlab runtime
|- opengl.vsprops -> sets the lib/include for opengl
Now in your versioning system, you provide a default for matlab.vsprops and opengl.vsprops that contains suitable dfeault values and a batch file to create them. This way you can checkout from the VCS, run a single file, edit the vsprops and start coding without too much hassle. For example:
main.vsprops -> versioned
matlab.vsprops.def -> versioned, contains defaults
opengl.vsprops.def -> versioned, contains defaults
create_vsprops.bat -> versioned, copies *.vsprops.def to *.vsprops

MSBuild imported script directory

In Visual Studio 2010 we have MSBuild for C++ project. Also we can add additional custom properties files "*.props" to projects, which are just MSBuild scripts.
Is it possible in imported "some.props" file know its directory?
for example there is "project.vcxproj" file and "common.props" file.
I would like to write something:
<IncludeDir>$( [and something for common.props file directory here] )\include</IncludeDir>
What should I write there?
%programfiles%\msbuild, which is accessible with $(MSBuildExtensionsPath), is the recommended place to put .props and .targets files that you would install and leave static. For example, many Microsoft teams that ship build process put their .targets files there.
If you plan to check-in those .props files for your team to use, or modify them, or maybe have different ones for different sets of source code, it's not such a good location; it isn't next to your source code and it requires admin rights to modify. In such cases, I recommend you put the files near your source code, perhaps at the root of a tree or subtree that includes all the projects for which it is relevant.
If you can put them under %Program Files%/MSBuild/ then you can use the MSBuildExtensionsPath property. This resolves to %Program Files%\MSBuild. If you cannot put the files there then another option would be to create an environment variable. In MSBuild you can access env variables just like properties. For example you can do <Message Text="Path :$(Path)"/> to print out the current path.

How to determine the folder where extension is executed from?

I'm writing some extension and I need to pull out data from the file that is included into vsix. But if I'll use Environment.CurrentDirectory I will not have this file because this folder points to VS folder not on the extension's one. How can I define it in a run-time?
System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase get the path to the executing dll.

In Visual Studio how to give relative path of a .lib file in project properties

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

Resources