Search code examples
c++visual-studio-2010static-linking

Referenced libraries in Visual Studio 2010 projects


Let's say I have a C++ Visual Studio 2010 solution with 2 projects: one main project with the program entry point and a second project with a static library (linked against the main one), that is used in other VS2010 solutions.

The static library project uses an additional third-party library (.lib). Currently, this third-party static library is set in the main project's Additional Dependencies field of the Linker -> Input section of the Property Pages, in order for the whole program to compile.

My question is, is there a way to add this dependency in the static library project itself, so I don't have to add it manually in each of the main projects from the different VS2010 solutions where the static library project is included?

Are there different ways to do this? Can I chose embed this third-party library in the .lib generated by the static library project? Is there any good practice or recommendations on doing this?

Thanks!


Solution

  • A static library is just like any other output of the linker - you can add additional dependencies in the 'librarian options' of your static lib project and they will be linked in as normal.