何时使用Visual Studio额外的依赖项? [英] When to use the Visual Studio Additional dependencies?

查看:474
本文介绍了何时使用Visual Studio额外的依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C ++中,您有头文件(.h),(.lib)文件和(.dll)文件。



提供位置以在三个不同的位置搜索这些文件:


  1. 配置属性=> C / C ++ => General =其他包含目录。


  2. 配置属性=>链接器=>常规=>附加库目录。


  3. 配置属性=>链接器=>输入= >其他依赖关系。
    这里你明确指定要包括的.lib文件。


问题是: p>

Q1:如果您在#1中指定了头文件,在#2中指定了lib,为什么/何时要在#3中指定任何内容?



Q2:我看到人在#3中包括一个特定的调试或发布版本的lib。你能在#3中指定一个库的调试或发布版本,并仍然在发布或调试模式下构建?理想情况下,应在此处提供哪个版本的库调试/版本?

解决方案



  1. 告诉链接器查找库的位置。

  2. 告诉链接器查找哪些库

Q1:通常如果你使用2,你几乎肯定需要使用3。 3告诉它要链接什么库,2告诉它在哪里找到那个库。当然,它也可以有多个库。



Q2:如果提供调试和发布库,您通常在调试版本中使用调试版本,在发行版中使用发行版本。在对话框的左上角,您可以选择要修改的配置。通常,您需要为调试和发布指定目录,但指定单个库,一个用于调试,一个用于发布。


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.

The questions are:

Q1: If you have specified the header file in #1 and the lib in #2, why/when would you want to specify anything in #3?

Q2: I see people including a specific debug or release version of a lib in #3. Can you specify either the debug or the release version of a lib in #3 and still build in release or debug mode? Ideally, which version of the library debug/release should be provided here?

解决方案

  1. Tells the compiler where to look for header files enclosed in angle brackets.
  2. Tells the linker where to look for libraries.
  3. Tells the linker what libraries to look for in those directories.

Q1: Generally if you use 2, you almost certainly need to use 3 as well. 3 tells it what library to link with, and 2 tells it where to find that library. Of course, it can be more than one library as well.

Q2: If a debug and release library are both provided, you typically want to use the debug version in a debug build and the release version in the release build. At the top-left corner of the dialog you select which configuration you want to modify. Typically you'll want to specify directories for both debug and release, but specify individual libraries, one for debug and one for release.

这篇关于何时使用Visual Studio额外的依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆