c++ - Visual Studio 2010 不会自动链接来自依赖项的项目中的静态库,因为它应该

  • 使用 C++ 控制台命令行项目创建新解决方案
  • 创建一个新项目,一个 C++ 静态库
  • 使命令行项目依赖于库
  • 确保在 Configuration => Linker => General 中打开“Link Library Dependencies”(默认情况下)
  • Visual Studio 仍不会链接库。

我该如何解决这个问题?它在 Visual Studio 2008 中工作。

最佳答案

这仍然有效,但是是 changed在 VS 2010 中:

"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."

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

关于c++ - Visual Studio 2010 不会自动链接来自依赖项的项目中的静态库,因为它应该是,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3795567/

相关文章:

android - 使用 gradle 签署产品 flavor

c++ - 从父 CMakeLists.txt 覆盖 CMake 中的默认选项(...)值

ubuntu - 试图包含一个库,但不断收到 'undefined reference to' 消息

ios - Swift 框架不适用于命名为 'Debug' 或 'Release' : No suc

java - Android 构建失败 - java.lang.IllegalArgumentExc

build - 构建和构建 OCaml 项目的首选方式是什么?

c# - 自动在 Visual Studio c# 项目中嵌入 mercurial 修订信息

android - 如何将构建时间戳写入apk

python - 有没有办法将 python 应用程序编译成静态二进制文件?

visual-studio-2010 - MSbuild 是否需要在构建服务器上安装 Visual