2

I have two projects in a solution (VS 2015). One project (A) is the entry project and generates an executable. The second project (B) generates a static library. I set B as a reference in A. However B needs itself to link against some precompiled static libraries that I have locally on the dev machine. How do I do this? If I set the project's configuration type to "static library" all the linker options disappear. Thanks

Edit: I added the external libs dependencies in project A as usual via Properties > Linker > Input > Additional Dependecies but this does not solve the issue.

underscore_d
  • 6,309
  • 3
  • 38
  • 64
Stefano Bider
  • 176
  • 2
  • 12
  • 1
    I think you mean to say that the second **project** links against other libraries. – AndyG Jul 26 '16 at 12:33
  • @AndyG no actually I meant exactly that project A links against the third party libraries. This is following the answer by Lightness Races in Orbit. I cannot in any way link against the third party libraries from the second project (project B as I called it) – Stefano Bider Jul 26 '16 at 12:47
  • Try going to project settings for Project B > Linker > Additional Dependencies, and in there add a path to the folder(s) that hold your "precompiled static libraries" – AndyG Jul 26 '16 at 15:02
  • @AndyG it is not possible to do so: the how Liker section in the project properties is not accessible if the project compiles to a static lib (as discussed throughout this thread...) – Stefano Bider Jul 26 '16 at 15:36

1 Answers1

1

If B is a static library then it can't "link against" anything. It's just an archive of individually compiled source files.

Its logical dependencies are inherited by the executable that uses it, i.e. A.

So add those third-party dependencies as references in A, alongside the reference to B.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
  • How do I do this? If I go to "add reference" I can only choose the subproject. – Stefano Bider Jul 26 '16 at 12:10
  • I have no idea, sorry. I do not use Visual Studio. – Lightness Races in Orbit Jul 26 '16 at 12:11
  • Thank you anyway. But please note that I am also not 100% sure about your answer: as an example in Xcode I can link to other binaries also from my binary libraries. – Stefano Bider Jul 26 '16 at 12:27
  • 1
    @StefanoBider Because your "binary libraries" become just another part of your final executable. So, again, their dependencies become its dependencies. References to those dependencies need to be evaluated during linking whenever the static library is used. Maybe Xcode has some shortcut around this; I don't know. – underscore_d Jul 26 '16 at 12:38