前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >VS中C++的包含目录、附加包含目录和库目录和附加库目录的区别

VS中C++的包含目录、附加包含目录和库目录和附加库目录的区别

作者头像
卡尔曼和玻尔兹曼谁曼
发布2019-01-22 17:36:42
3.1K0
发布2019-01-22 17:36:42
举报

对Visual Studio中C++的包含目录、附加包含目录和库目录和附加库目录的区别不是很清楚,参考别人的文章整理出来的。供大家分享学习!

Visual Studio C++工程中,右键一个Project,可以发现有两个地方设置Include的相关目录:

1. VC++ Directories -> Include Directories 2. C/C++ -> General -> Additional Include Directories

MSDN上的解释如下:

“VC++ Directories -> Include Directories” : Directory settings displayed in the window are the directories that Visual Studio will search for include files referred to in your source code files. Corresponds to environment variable INCLUDE. More information : http://msdn.microsoft.com/en-us/library/t9az1d21(v=vs.80).aspx

“C/C++ -> General -> Additional Include Directories”: The directory to be added to the list of directories searched for include files. More information : http://msdn.microsoft.com/en-us/library/73f9s62w(v=vs.80).aspx

下面这个链接中给出了编译器在编译过程中查找包含目录(Include文件)的顺序:

The compiler searches for directories in the following order:

  1. Directories containing the source file.
  2. Directories specified with the /I option, in the order that CL encounters them.
  3. Directories specified in the INCLUDE environment variable.

其中Order2中的/I是由C/C++ -> General -> Additional Include Directories设置的。

而Order3中的INCLUDE是由VC++ Directories -> Include Directories设置的。

同理,

1. VC++ Directories -> LibraryDirectories 2. Linker -> General -> Additional Library Directories

也一样。

所以在VS中开发C++程序,我们一般是这样设置的:

In C++, you got the header files (.h), the (.lib) files and the (.dll) files.

In Visual Studio, you provide the location to search for these files in three different places:

  1. Configuration Properties => C/C++ => General => Additional Include directories. Here you list out the "include" directories that you want searched and made available.
  2. Configuration Properties => Linker => General => Additional Library directories. Here you list out the "lib" directories that you want to be searched and made available.
  3. Configuration Properties => Linker => Input => Additional dependencies. Here you explicitly specify the .lib files that want to include.

就是说我们一般使用C/C++和Linker下面的设置,而一般不建议使用VC++下面的设置。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2015年01月20日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档