static libraries and linking

Jul 18, 2008 at 5:34pm
Okay, I'm coming into some legacy code at my new job here and need some input.

We have a GUI app on top.
The GUI links to SL1.lib.

In the SL1.lib, it uses forward declarations to use SL2.lib.

SL1 compiles just fine (and why shouldn't it with forward declarations).

GUI will not link properly however. It's spitting out LNK2019 to the function names in SL2.lib.

My question is: How do I need to reference SL2.lib? Straight from the GUI code? Or is SL1.lib going to look around for SL2.lib at runtime? I'm confused on how to use a static library from a static library in a top level exe since there is no linking.

Does that make sense?

-Zakk
Jul 19, 2008 at 2:34am
Depends on your linker.

Some things you can try are:

1) Make sure that you are linking against both libraries;
2) If you are, then try reversing the link order of the libraries.

Some linkers (like ld) require that interdependent libraries get linked in a particular order.
Jul 19, 2008 at 9:32pm
Every linker I have worked with works like this:
Libraries will usually link blind, i.e. they will build without visibility the object code for external references. The only time these external references are checked is when the library gets linked into an app.

The app needs linking to all libraries and their dependencies.
Topic archived. No new replies allowed.