简体   繁体   English

在VS2010中,是否存在用于私有标头和库的正确位置?

[英]In VS2010 is there a correct placement for private headers and libs?

我应该在哪里放置.h.lib文件,以便仅编写#include <mylib.h> (或"mylib.h" ),并且编译器和链接器将为我的所有 c ++项目找到它们?

There is no one single place on the computer where you can put .h / .lib files and expect them to be included in all C++ projects. 在计算机上没有一个地方可以放置.h / .lib文件,并希望它们包含在所有C ++项目中。 The directories which are searched for .h / .lib files is a completely configurable item. 搜索.h / .lib文件的目录是一个完全可配置的项目。 Hence there is no one true include directory. 因此,没有一个真正的包含目录。

A potential option is changing the global MSBuild files for the machine. 一个可能的选择是更改计算机的全局MSBuild文件。 C++ projects inherit a portion of their settings from this file and it could be used to force down a set of includes to the vast majority of projects. C ++项目从此文件继承其设置的一部分,并且可以用于将一组包含项强制降低到绝大多数项目。 However it's a bit of a sledge hammer option and won't be 100% effective. 但是,这是一个大铁锤选项,并且不会100%有效。 Any individual project can still override these defaults (or simply not use MSBuild). 任何单个项目仍可以覆盖这些默认值(或根本不使用MSBuild)。

It is possible though to have a unified .h / .lib directory on your machine and then manually point every C++ project at that directory 可能在您的计算机上有一个统一的.h / .lib目录,然后手动将每个C ++项目指向该目录

  • Right click on the C++ project 右键单击C ++项目
  • Navigate to Configuratin Properties -> C/C++ -> Command Line 导航到Configuratin属性-> C / C ++->命令行
  • Add /I c:\\path\\to\\unified\\include 添加/I c:\\path\\to\\unified\\include

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM