Visual Studio 2010 不会像应该的那样从属于依赖项的项目中自动链接静态库 [英] Visual Studio 2010 not autolinking static libraries from projects that are dependencies as it should be supposed to

查看:25
本文介绍了Visual Studio 2010 不会像应该的那样从属于依赖项的项目中自动链接静态库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 使用 C++ 控制台命令行项目创建新解决方案
  • 创建一个新项目,一个 C++ 静态库
  • 使命令行项目依赖于库
  • 确保在配置 => 链接器 => 常规(默认情况下)中打开链接库依赖项"
  • Visual Studio 仍不会链接库.

我该如何解决这个问题?它适用于 Visual Studio 2008.

How can I fix this? It worked in Visual Studio 2008.

推荐答案

这仍然有效,但 已在 VS 2010 中更改:

在 VS2010 中,我们停止支持定义隐式引用的项目依赖项,我们还引入了一种在项目级别定义项目依赖项的新方法.由于项目引用和项目依赖项是接近的概念,都适用于项目,因此在项目文件中以一致的方式将它们一起表示是有意义的.正如您将在下面的片段中看到的,项目引用定义和项目依赖项定义之间的唯一区别在于定义输出程序集包含的元数据/排除到主项目链接命令行中/从主项目链接命令行中排除.尽管我们没有删除项目依赖项"对话框,但我们建议通过框架和引用"对话框定义新的项目依赖项.您需要将属性页 UI 中的引用程序集输出"属性设置为 false(对于项目依赖项)和 true(对于项目引用)."

"With VS2010, we stopped supporting project dependencies defining implicit references and we also introduced a new way of defining project dependencies at the project level. Since a project reference and a project dependency are close concepts, both applying to a project, it made sense to have them represented together, in a consistent way, in the project file. As you will see in the snippets below, the only difference between a project reference definition and a project dependency definition consists in metadata that defines the output assembly inclusion/exclusion into/from the main project link command line. Although we did not remove the "Project Dependencies" dialog, we recommend defining new project dependencies via the "Framework and References" dialog. You need to set the "Reference Assembly Output" property in the property page UI to false for a project dependency and to true for a project reference."

只需在控制台项目上右键,选择属性->通用属性->框架和引用->添加新引用",添加静态库项目;还要检查右侧的链接库依赖项"是否为 True.似乎适用于调试和发布版本.你每天学习新的东西.;)

Just right-click on the console project, select "Properties->Common Properties->Framework and References->Add New Reference" and add the static library project; also check that "Link Library Dependencies" is True on the right hand side. Seems to work for debug and release builds. You learn something new every day. ;)

这篇关于Visual Studio 2010 不会像应该的那样从属于依赖项的项目中自动链接静态库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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