1

I have a C++ solution with multiple projects in VS2019. I've just added a new static library project, and this static library needs to use some functionality contained in another existing static library project.

When I right-click References under this new static library, and add a reference to the existing static library, the icon under References shows a warning icon (yellow triangle with exclamation mark).

I've looked at some Microsoft documents on broken references:
https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2008/ayds71se(v=vs.90)?redirectedfrom=MSDN

None of the answers in the 'broken references' page apply to my situation, because I'm using the Wizard to create the reference and it's broken right away; I certainly didn't move the file on disk or anything like that.

A similiar issue is reported here with no clear resolution:
https://developercommunity.visualstudio.com/content/problem/632599/the-microsoftvisualstudioprojectsystemreferencesun.html

In other projects within my solution, references to the existing static library do work without any warning. The main difference that I can see is that the projects referencing the library are MFC applications, not static libraries themselves, but I don't see why a static library should have any issues with referencing another static library.

When I double-click the reference, I get a pop-up message:

The "Microsoft.VisualStudio.ProjectSystem.References.UnresolvedBuildDependencyProjectReference" reference could not be resolved.

What am I doing wrong here?

afarley
  • 781
  • 6
  • 26
  • add reference is manly for C#. For C++ it's more work to do: https://stackoverflow.com/a/61350540/2805305 Does this solves your problem? – bolov Jun 30 '20 at 21:12
  • @bolov It's strange that the References drop-down exists for every project if it's only meant for C#. I'm not sure if the link you attached is referring to nested static libraries, or just how to link a static library to an application. Anyway, it sounds like all I should need to do is point my containing library to the headers from the nested library, and it should compile that way. I think 'linking' might be the wrong terminology for what I'm doing, since I'm just trying to compile the containing static library which references another static library. – afarley Jul 01 '20 at 00:38
  • using a library in an terminal application or using a library in another library: the same concepts apply. – bolov Jul 01 '20 at 11:26

1 Answers1

0

Based on the discussion here, it seems that linking static libraries using 'Add Reference' may not be possible/requires some workarounds:

Linking static libraries to other static libraries

I will look for alternative approaches rather than trying to reference static libraries from within a different static library.

afarley
  • 781
  • 6
  • 26
  • It is my experience with more recent versions of Visual Studio (VS 2015, 2017 and 2019) that you do not want to have any references in static library projects. You just want to have a complete reference list in the dlls or exes that use those static libraries. – GTAE86 Mar 04 '21 at 20:31