My thanks to all who replied to my FORTRAN problem.
(Kevin was my first respondee and was correct)
The order of the arguments was wrong!
This now works properly:
f77 -o test.run test.f -L. -lgq610
============================================
***********************************************************
Note: I have included the various responses, as I
gathered some useful info that might interest others.
***********************************************************
: I need to create a fortran library from a collection of subroutines. They are
: interdependent and so the library needs to be "searched" as often as needed
: in order to resolve all references.
:
: This is a summary of what I believe is the correct way to proceed (I've
: had some local help but it's not being solved).
:
: 1) compiled all routines: f77 *.f -O -c
:
: 2) started the library : ar rcv libgq610.a sub1.o (the 1st subroutine)
:
: 3) added remaining routines one at a time:
:
: ar qv libgq610.a sub2.o
: ( etc. until all are loaded)
:
: 4) now compile/link/load:
:
: f77 -L. -lgq610 -o test.run test.f
:
====================================================================
Andrew...
Your order is wrong. Libraries must go at the end. Try:
f77 -o test.run test.f -L. -lgq610
Kevin W. Thomas
Sun System Administrator & Meteorologist
National Severe Storms Laboratory
Norman, Oklahoma
==========================================================================
you may need to move the -llibname to the end of the compile line.
that's probably not it, tho.
our library doesn't self-reference in a major way. however, the
recommended way to do ar style libs involves tsort before inserting.
check tsort man page.
it may be necessary to -llibname -llibname , ie, link to it more
than once. libs aren't searched and re-searched. Just one pass.
how much tsort will lessen that pain, I don't know.
no other ideas.
j.
--
Jay Scott 512-835-3553
Applied Research Labs, Computer Science Div.
University of Texas at Austin
==========================================================================
Try:Quote:> 4) now compile/link/load:
> f77 -L. -lgq610 -o test.run test.f
f77 -o test.run test.f -L. -lgq610
Archives libraries are searched once for references when they are
encountered. It isn't until after the library is processed that
the references from test.f are detected.
Rod.
==========================================================================
Oh, I see. The usage message could be more intuitive. I filedQuote:> When you do an "f77" (no arguments) it tells you that
> the order is: f77 [options] files
> Sooo, I took this to mean that, anything that has an "-"
> prefacing it (f77 -flags) meant that it was an option.
a bug to try and get it improved.
Rod.
==========================================================================
BTW ...
You can add *all* the objects to the archive in one go ...Quote:> 3) added remaining routines one at a time:
> ar qv libgq610.a sub2.o
> ( etc. until all are loaded)
ar rcv libgq610.o sub1.o sub2.o ....
Or you could generate a shared object (in which case your previous
link-line would have worked :-). Confused? ;-) Check out the
``Linker and Libraries Guide'', which is part of the Software
Developers Guide in the Answerbook.
Rod.
==========================================================================
That's the procedure I've used with success to create the library. You may
need to
reorder the arguments in the later compilation:
f77 -o test.run test.f -L. -lgq610
Mike Johnson
==========================================================================
The linker ld starts with the main program and searches for symbols therein
left-to-right. You should mention "-o test.run"
before -L and -l. One also usually puts options before filenames, although
in the first "f77"-lines it does not matter.
f77 -O -c sub1.f
f77 ...
ar rcv libgq610.a sub1.o
ar ...
f77 -o test.run test.f -L. -lgq610
You wisely named your executable "test.run" and not "test". Naming
a program "test" might interfere with /bin/test and cause all sorts
of weirdness.
If you have multiple libraries, they also must be in the correct order,
left-to-right. If a routine in your libgq610.a uses a function from
/usr/lib/libm.a, you must say
... -lgq610 -lm
and not
... -lm -lgq610
Using Makefiles is also suggested.
- Andi Karrer
==========================================================================
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
mmmm/~~~~
_!_______+--- ___ _________ _________ ____/\.
_|________|__| |_____| |_A_&_P_| |_A_&_P_| >E-MAIL< |_____|
/o=OOOO -OOOOo ~ oo oo ~~ ooo ooo ~~ ooo ooo ~~ oo oo ~~ oo oo
===================================================================
Andrew A. Paine, CS (614) 292-6518 Office
410 Arps Hall (614) 292-3906 FAX
The Ohio State University (614) 438-8413 (digital pager)
1945 North High Street
Columbus, Ohio 43210-1172
Yesterday is history,
Tomorrow's a mystery,
Today is a Gift and that's we call it the Present !
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/