包含目录和附加包含目录(include、additional Include)
Visual Studio C++工程中,右键一个Project,可以发现有两个地方设置Include的相关目录:
1. VC++ Directories -> Include Directories
2. C/C++ -> General -> Additional Include Directories
“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.
“C/C++ -> General -> Additional Include Directories”: The directory to be added to the list of directories searched for include files.
编译器在编译过程中查找包含目录(Include文件)的顺序:
The compiler searches for directories in the following order:
Directories containing the source file.
Directories specified with the /I option, in the order that CL encounters them.
Directories specified in the INCLUDE environment variable.
其中Order2中的/I是由C/C++ -> General -> Additional Include Directories设置的。
而Order3中的INCLUDE是由VC++ Directories -> Include Directories设置的。
库目录和附加库目录同理(lib, additional Lib)
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:
Configuration Properties => C/C++ => General => Additional Include directories. Here you list out the "include" directories that you want searched and made available.
Configuration Properties => Linker => General => Additional Library directories. Here you list out the "lib" directories that you want to be searched and made available.
Configuration Properties => Linker => Input => Additional dependencies. Here you explicitly specify the .lib files that want to include.
就是说一般使用C/C++和Linker下面的设置,而一般不建议使用VC++下面的设置。
参考文献: VS中C++的包含目录、附加包含目录和库目录和附加库目录的区别_给永远比拿愉快-CSDN博客_包含目录和库目录