Question

I have few header files (+ some cpp files) and I want them to be accessible from all VS C++ projects. For example, I have these files: myclass.h myclass.cpp and I want to #include <myclass.h> from all projects I create (and also I want myclass.cpp to be accessible from projects where myclass.h is included).

Was it helpful?

Solution

What you want to do is to put your common code into a sensible location. Now you can modify the configuration of your project to point at your additional include directories.

There are various ways you can do this. The simplest is to right click your project, select "properties", open the "Configuration Properties" section of the property page dialogue, and select "VC++ Directories". There are two setting under there you would need to modify... "Include Directories" and "Source Directories". Double click them to bring up an edit dialogue.

The next possibility is to create your own custom property sheet. See the relevant documentation here: http://msdn.microsoft.com/en-us/library/669zx6zc.aspx#bkmkPropertySheets

You'll need to bring up the "Property Manager"... for me, this was under the main "View" menu, under "Other Windows". When the property manager is up, you can right-click a particular build configuration or project and select "Add New Project Property Sheet". You can now set up a whole bunch of config options, and save them out to a "props" file.

Next time you want to make a project with this same set of settings (eg. the same include and source paths that your common code is in), you can use "Add Existing Property Sheet" instead.

It is possible to modify the standard property sheets. This is probably not a sensible thing to do!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top