cplusplus.com cplusplus.com
cplusplus.com   C++ : Forums : General C++ Programming : static libraries and linking
  Search:
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forums
Forums
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Articles
Lounge
Jobs

-

question  static libraries and linking

zakkhoyt (5)
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
|
jsmith (400)
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.
|
bnbertha (404)
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.
|

This topic is archived - New replies not allowed.
Home page | Privacy policy
© cplusplus.com, 2000-2008 - All rights reserved - v2.2
Spotted an error? contact us