Visual Studio 2012 link errors with static libraries

后端 未结 1 1251
你的背包
你的背包 2021-02-19 17:29

I recently upgrade to 2012 from 2005 (I\'m pretty sure) and ran into link errors when building my solution. I ran out of ideas after hours of searching google and putsing aroun

相关标签:
1条回答
  • 2021-02-19 18:01

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

    0 讨论(0)
提交回复
热议问题