关于VS中包含库、附加包含库、

转载:https://blog.csdn.net/qing101hua/article/details/53841827

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

对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++下面的设置

上一篇:Intel微处理器学习笔记(三) 不可见寄存器


下一篇:docker基础内容讲解