Re: [SLUG] Libraries/Programming Question

From: Andrew M Hoerter (
Date: Sun Sep 07 2003 - 16:46:04 EDT

On Sun, 7 Sep 2003, Paul M Foster wrote:

> Well, that's bizarre. Actually it works fine without the first -lfl but
> with the last one. I've heard of having to call libraries in a certain
> order, but I never grasped why. I see this is a case of it. Thanks.

The reason is that UNIX linkers are dumb. They scan libraries and object
files in the exact order specified and don't make multiple passes to
collect all the required symbols.

To avoid this problem most people link in a particular order such as:

myobj.o bla.o foo.o -lapplibrary -lapplibrary2 -lsyslibrary -lsyslibrary2

By ordering objects from "highest level" to "lowest level" dependencies
will tend to be satisfied properly. Just wait until you have a circular
dependency at link time, that's when things get really "fun".

This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS). Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.

This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 20:21:13 EDT