0

Rather than having to wade through the project options linking the relative directories for every new project I start, is there any way I can just link libraries in Visual Studio Express 2010 'globally', so I can just start a new empty project and call the header files whenever I need it?

(The libraries I'm talking about are SDL and libtcod.)

Ulrich Eckhardt
  • 16,572
  • 3
  • 28
  • 55
  • 5
    Visual Studio allows, among other things, setting the default include path included with all new projects. See [C++ Property Sheets](http://msdn.microsoft.com/en-us/library/a4xbdz1e(v=VS.80).aspx) for info on how to do this (assuming I understood your question). – WhozCraig Mar 25 '13 at 04:52
  • @WhozCraig: Unfortunately, they removed those options a few years back :( – Mooing Duck Mar 25 '13 at 20:17
  • 1
    @MooingDuck They absolutely did not. In fact, they've expanded property sheets slightly in [2010](http://msdn.microsoft.com/en-us/library/669zx6zc(v=vs.100).aspx) and [2012](http://msdn.microsoft.com/en-us/library/669zx6zc.aspx), with new documentation covering both versions (linked on the year). I can't comment on GUI options to do so, since I pared down and optimized my project files manually. – ssube Mar 25 '13 at 20:22
  • 1
    @MooingDuck I think we're thinking of different parts of the project config. They did, in fact, remove the "set the global paths here" options from VS2010 and later. but they were replaced with expanded functionality of property *sheets*, which are includable-special-sauce you can configure and reference from your project(s). Its *almost* the same thing, but actually more flexible. peachy's description below is pretty good. – WhozCraig Mar 25 '13 at 22:54

2 Answers2

3

You absolutely can, and it's incredibly convenient. I recently described the build setup for one of my projects in some detail as an answer to this question. It relies on Visual Studio property files (this link is similar to WhozCraig's comment, but more recent and somewhat broader), which can contain almost anything a project file can, and can be included from project files.

In short, all of the dependency, general settings, and version information is provided by property files. I then overwrite some of the settings on the command line for automated builds. It took a little bit of time to set up, but works very well.

Setting up property files for common settings, build configurations, and dependency paths is nice. Splitting all paths into a separate, rarely-updated property file is excellent for sharing code with other people, as well. There are mechanisms for fairly sophisticated/complicated string comparison and conditional requirements on particular sections of the property file (based on build configuration, project, and a variety of other settings). You can also declare variables, which may later be used in other keys (using VS' $(var) syntax) or passed as preprocessor definitions into the build itself.

Community
  • 1
  • 1
ssube
  • 47,010
  • 7
  • 103
  • 140
  • http://blogs.msdn.com/b/vcblog/archive/2010/03/02/visual-studio-2010-c-project-upgrade-guide.aspx "VC++ Directories are no longer supported in VS2010 through Tools->Options page. " Though it continues and says that this option has been moved to "Microsoft.cpp..users.props". [This blog post also talks about it](http://blog.gockelhut.com/2009/11/visual-studio-2010-property-sheets-and.html). So yeah, they're in properties sheets now. – Mooing Duck Mar 25 '13 at 20:44
  • 1
    As far as I understood it, the removal of those global directories was to push them into the project or solution scope, and setting them for your entire user profile was discouraged (but obviously allowed). A property sheet on the project itself is, IMO, the cleanest way to handle that and make it easy for others to work with your code. I was annoyed at them removing global paths at first, but once I got property sheets set up, it's been working very well and made moving to a CI environment relatively painless. – ssube Mar 25 '13 at 20:47
  • +1 pretty-much exactly what I was referring to above. Thanks for fleshing this out. – WhozCraig Mar 25 '13 at 22:56
0

You can place the library header files (.h) in Visual Studio's \include folder and library files (.lib) in \lib folder. This way, you can directly call header file (.h) and link libraries from Project Properties > Link. Anyway Visual studio has removed the option to set project properties globally since VS2010. So there's no way you can do that again (unless MS adds it again).

CrazyFellow
  • 420
  • 3
  • 8
  • Visual Studio most certainly did not remove global properties, in any current version. They may not be accessible through the GUI, but property sheets still work and have a fairly thorough hierarchy when searching for project settings. I maintain projects in VS2010 and 2012 formats, both using near-identical property sheet-based configurations. – ssube Mar 25 '13 at 20:20
  • @MooingDuck: If I'm guessing at what you mean correctly (being able to add solution-level include/library paths), they did do that and it was a little annoying. For most purposes, property sheets seem to fill in all the holes and may be the suggested replacement. – ssube Mar 25 '13 at 20:42
  • @peachykeen: You're right, I misremembered. They moved the option _from_ where it used to be to properties sheets. my bad. – Mooing Duck Mar 25 '13 at 20:47