What does the "Link Library Dependency" linker option actually do in Visual Studio 2010 - 2015 and upwards?

Martin Ba picture Martin Ba · Oct 7, 2011 · Viewed 44.2k times · Source

Up to VS2008, you set your native C++ project dependencies up in the solution file (Project Dependencies ...) and if (by default) the Linker Option

Properties -> Linker -> General : Link Library Dependencies = Yes

is set, the Visual Studio Build will automatically link in the .lib files of all projects (DLLs, LIBs) that this project is dependent on will be "statically" linked in.


Side Note: Microsoft changed how the dependencies worked in VS2010 and you are now supposed to add the dependency directly to the project

Common Properties -> Framework and References : (List of depenencies) 

    (each lib/dll has a separate option: 
     Project Reference Properties -> Link Library Dependencies : True|False

I'm fine with that. This is not what this question is about.

(One explanation here: Flexible Project-to-Project References.)


It is still possible however to define project dependencies on the Solution level and the General Linker option is also still there. However it doesn't work. See:

and especially see here (acutal question follows)

Where Microsoft confirms that the Linker Option doesn't do what the rest of the world's population expects it to do, and adds the following explanation:

Thanks for reporting this feedback. The issue you are experiencing is by design. "Link Library Dependency" is a flag that only dictates whether or not to pass the library as an input to the linker. It does not find the dependency automatically. As a customer you will have to define the depedency manually as you suggest.

Can anyone explain what that means, or more to the point: What does the "Link Library Dependency" linker option actually do in Visual Studio 2010?

What is an "input to the linker" that isn't actually linked supposed to be?

Answer

Hans Passant picture Hans Passant · Oct 7, 2011

You have to give the setting the proper value to bring clarity:

enter image description here