Visual Studio 2012 link errors with static libraries

﹥>﹥吖頭↗ 提交于 2019-12-04 00:18:25

Visual Studio 2005 did some magic with project dependencies where it would automatically link in any .lib outputs (I unfortunately was the developer that helped implement it). This appears to have been removed since, I suspect, Visual Studio 2010 when the old Visual C++ build system was replaced with MSBuild.

However, the "automatic linking of static library dependencies" feature can still be found via project references:

  • Right click on the App project and select "References..."
  • Click "Add New Reference".
  • Check the static library project and press OK.
  • Build.

You should now see the static library being automatically linked in. Note that project references also imply a project dependency.

If you prefer to use a project dependency instead, you'll need to add the static library to the linker's additional dependencies property on the "App" project, like you would for any other static library input.

Edit: also, you'll see a property called "Link Library Dependencies" on the project reference. This controls whether or not the .lib output of the referenced project gets linked in or not (defaults to true).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!