对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:
其中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:
就是说我们一般使用C/C++和Linker下面的设置,而一般不建议使用VC++下面的设置。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有