[Prev] Thread [Next]  |  [Prev] Date [Next]

Re: order dependence of -l option Steve Kargl Wed Feb 08 23:00:24 2012

On Wed, Feb 08, 2012 at 10:19:23PM -0800, Brad Finney wrote:
> Why must the -l<library> argument be placed after the fortran source 
> file name when compiling with gfortran.
> The following does not find object codes in libutil.a
> gfortran -Llib -lutil a.f90
> but the following works as expected
> gfortran -Llib a.f90 -lutil
> I understand that the order of -l arguments matter is there are multiple 
> libraries, but I do not understand why gfortran doesn't just pass the 
> -l<library> arguments on to the linker after creating a.o.

a) history
b) simplicity
c) causality
d) all of the above

How is the loader to know that _foo in -lutil is
needed by the code in a.f90?  Or, are you suggesting
that the loader should retain all symbols in -lutil?