包含路径(include path) 库路径(lib path)VC++2010 (附加)包含目录 (附加)库目录

来源:互联网 发布:我们来了网络更新时间 编辑:程序博客网 时间:2024/05/21 09:30

VC++2010项目属性设置有很多,如果有什么不明白的,单击选择项目属性窗口的某一项设置,按F1(或者单击窗口的帮助按钮),就可以在msdn上看到相关解释了(使用联机帮助的话)。本文的内容整理自msdn,先给出链接,这里只对(附加)包含目录,(附加)库目录进行总结。


“VC++目录”属性页

这里面有包含目录(Include Directories)、库目录Library Directories)等等,点开看看,里面有VC安装目录、Windows SDK目录、.NET Framework目录,是VC++默认设置好的。对于额外的头文件、库文件,我都在“附加包含目录”、“附加库目录+附加依赖项”处指定(见下文)。

另见一篇专门介绍VC++目录的博客文章:VC++ Directories


"C/C++"

/I(附加包含目录) 指定(第三方的)头文件的目录

附加包含目录(Additional Include Directories)(/I ) :Adds a directory to the list of directories searched for include files.

To add more than one directory, use this option more than once.Directories are searched only until the specified include file is found.

You can use this option with the Ignore Standard Include Paths(/X (Ignore Standard Include Paths))option.


附加包含目录 与 “VC++目录”的“包含目录” 的关系如下:

The compiler searches for directories in the following order:

  1. Directories containing the source file.

  2. Directories specified withthe/I option(即附加包含目录), in the order that CL (编译器cl.exe)encounters them.

  3. Directories specified in the INCLUDE environment variable(即“VC++目录”的“包含目录” ‘Include Directories’).

有关“C/C++ -> 代码生成 -> 运行时库”的内容请参考这里

Choosing the Correct C/C++ Runtime Library


“链接器”

/LIBPATH附加库目录 .lib file的所在目录,

“VC++目录”的“库目录”的关系如下:

附加库目录(Additional Libpath)(/LIBPATH)Specifies a path that the linker will search before it searches the path specified in theLIB environment(即“VC++目录”的“库目录” ‘Library Directories) option.

Use the /LIBPATH option to override the environment library path.The linker will first search in the path specified by this option, and then search in the path specified in the LIB environment variable(即“VC++目录”的“库目录” ‘Library Directories).


附加依赖项:指定要添加到链接命令行的附加项(.lib file的名字)。

see .Lib Files as Linker Input 


更多

下面也是些相关的东西:

LIB Reference

/DLL

/DEFAULTLIB

《深入理解计算机系统》链接那一章。

《程序员的自我修养——链接装载与库》windows dll 那一章。

Beginer's Guide to Linkers


有时,项目配置不仅适用于当前项目,还适用于之后的项目;为了避免重复配置,可以使用“属性管理器”中的用户属性表,

用户属性表会影响计算机上的特定用户的所有项目,如下图所示(Microsoft.Cpp.Win32.user):


这样之后的项目就都会有这儿的配置了。还可以使用项目模板。


See also:

属性表

如何:创建项目模板    “导出模板”向导