Visual Studio 2010 not autolinking static libraries from projects that are dependencies as it should be supposed to

  • Create a new solution with a C++ console command-line project
  • Create a new project, a C++ static library
  • Make the command-line project depend on the library
  • Make sure "Link Library Dependencies" is turned on in Configuration => Linker => General (it is by default)
  • Visual Studio will still not link the library.

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


Solution 1:

This still works, but was changed in 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."

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

Solution 2:

They changed the UI for adding C++ project dependencies in VS2010, but oddly enough, without removing the old UI, or in any way indicating that it no longer works.

To create the dependency in VS2010, you need to use "Add New Reference" (can be found in project properties), and maybe also in the project's right-click menu (don't have VS here to check)

The old "Project Dependencies" dialog is basically broken now.