【个人笔记】Visual Studio 2015工程属性中包含目录和库目录

本文源自:http://blog.csdn.net/s9434/article/details/53509453

Directory Types

You can also specify other directories, as follows.

Executable Directories

Directories in which to search for executable files. Corresponds to the PATH environment variable.

Include Directories

Directories in which to search for include files that are referenced in the source code. Corresponds to the INCLUDE environment variable.

Reference Directories

Directories in which to search for assembly and module (metadata) files that are referenced in the source code by the #using directive. Corresponds to the LIBPATH environment variable.

Library Directories

Directories in which to search for libraries (.lib) files; this includes run-time libraries. Corresponds to the LIB environment variable. This setting does not apply to .obj files; to link to an .obj file, on the Linker General property page, select Additional Library Dependencies and then specify the relative path of the file.

Source Directories

Directories in which to search for source files to use for IntelliSense.

Exclude Directories

Directories not to search when checking for build dependencies.


进入工程属性:选择【VC++目录】,经常用的是【包含目录】、和【库目录】的添加。

建工程时,所需要的库可以不和工程在同一目录(不同磁盘),也可以在同一目录(即都在工程目录下)。

1.如果所需要的库和工程在不同磁盘,则将此工程给别人使用时,别人也需包含所需的库,否则,该工程则无法运行。

2.如果把所需的库放在工程目录下,则此工程移植到其他电脑时,可以直接运行,而不需要其他配置。

新建VS项目时,

新建VS2015工程,项目名称:A(路径自己设置),此时会在路径下生成和项目名称相同的文件夹A,在A这个文件夹下有三个文件(未编译的情况下):A(文件夹)、A.sln、A.sdf    ,你自己添加的.cpp或者.h文件则在A文件夹下(注意是A文件下的A文件夹)。

本文简略介绍一下,把相应的库添加到工程目录下的方法:

既然要可靠移植到其他电脑,则我认为不可以用绝对路径,因为绝对路径包含了磁盘名称,而移植时磁盘名称是未知的。所以,要用相对路径,这里先介绍常用的表示相对路径的方法。

1)./ 表示当前目录

2)../ 表示父目录(当前目录的上一级目录)

3)/ 根目录


此处介绍的需要在【包含目录】、和【库目录】写入的文件路径是和.cpp或.h同级的(同级目录)。


上图中的VC++目录,包含目录如下所示,

如果的库文件夹和.sln在同一级,则此处,用../(父目录),因为.cpp表示当前目录

一般需要包含都含两个文件夹

include里面是.h或.cpp文件,这个include则要被包含在【包含目录】中,最上图所示。

而lib文件夹里面包含了.lib文件,这个lib则要被包含在【库包含目录】中,最上图所示。

也可以使用  

#pragma  comment(lib, "libconfig.lib")//此时libconfig.lib需要和.h文件在同级目录下。


之后,【附加依赖项】中添加


注意:debug和release都需配置


对应的libconfig.dll则放入和.sln同级的debug或release目录中。要不然虽然编译不报错,但是运行时会出现确实libconfig.dll的提示


转载仅是为了学习方便!在这里感谢原创作者。

猜你喜欢

转载自blog.csdn.net/flysky_jay/article/details/79453042