Visual Studio 2010 Not Autolinking Static Libraries from Projects That Are Dependencies as It Should Be Supposed To

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

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

VS2010 static linking issue

Have a look at following links:

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

Behavior of Link Library Dependencies in 2010

Unresolved Externals When Build a VC++ Project with Chained Static Lib Dependencies

Flexible Project-to-Project References

Visual studio unit testing a static library; prevents additional dependencies in main project

Static library is a collection of object files. No linker involved. Dependencies are not being resolved. It only requires headers to build.

Now, when you finally create an executable (or a dynamic library), you should link all the necessary dependencies.

However, note that additionally to the "classic" build process described above, Visual Studio IDE provides abstractions (convenient, but sometimes a bit misleading, especially for novices), called "Project references" and "Project dependencies". There are options to make a static library "depend" on other static libraries. Also, executable can depend on that first static library. When "Link dependencies" is enabled, Visual Studio will resolve entire dependency chain recursively and link all the necessary into your executable.

See also:

  • What does the “Link Library Dependency” linker option actually do in Visual Studio 2010?

  • MSDN - C/C++ Building Reference

  • MSDN - Walkthrough: Creating and Using a Static Library (C++)

  • What is an undefined reference/unresolved external symbol error and how do I fix it?

A project with a third-party library is not being built

This may not answer your question directly, but I think not many people are aware of this. You can "install" sfml for you project by opening you project, going Tools->NuGet Package Manager->Manage NuGet Packages for Solution... There you can browse for example for "SFML" and just install needed packages. It is much easier to work with than linking it manually, but maybe you cannot use it for some reason. As for why linking does not work in your case you'd need to show us your Linker Settings.



Related Topics



Leave a reply



Submit