This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: order dependence of -l option




On 2/8/2012 10:31 PM, Steve Kargl wrote:
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?

No, I am expecting exactly what happens. The loader scans for missing symbols in library libutil.a which is found either in the working directory or the directory identified as lib. The question is why is the order of the -l option critical when most other options can be in any order. Obviously I am missing some key feature/characteristic of the process. I don't have any problem following the "rule", but understanding the why is helpful. Sorry to trouble you with the question.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]