ar cr [libname] [routine1.o] ...... [routinen.o]or in verbose mode,
ar crv [libname] [routine1.o] ...... [routinen.o]For example,
ar crv libmysubs.a one.o two.o three.owill create a library of routines named libmysubs.a.
f77 -c one.f f77 -c two.f . f77 -c six.for
f77 -c one.f two.f three.f four.f five.f six.f
ar crv libsubsmy.a one.o two.o three.o four.o five.o six.o
Strauss' link editor can make the multiple passes needed to resolve all of the subprogram references, so the library is now ready to use on Strauss. However, to create the library with more efficient ordering, use the routines "lorder" and "tsort". For this example, you would type
ar crv libmysubs.a `lorder one.o two.o ... six.o | tsort`For small libraries such at this one with only six routines, the difference in load time is negligible. However, for larger libraries, the lorder command may allow for an efficient access of the library during the link edit process.
If main.f is a program that calls one or more of the routines in libmysubs.a, AND libmysubs.a is in the same directory as main.f, you can compile and link all the routines by adding libmysubs.a to the f77 command:
f77 main.f libmysubs.a -o main.exeThis only works if libmysubs.a is in the directory that contains main.f. If it is not, you must either specify the full pathname for the library, use the -L option, or use the environment variable LD_LIBRARY_PATH. For a description of these choices see the tip sheet "Compiling and Executing FORTRAN Programs Requiring Subprograms".
f77 -c five.f ar r libmysubs.a five.oNote that there is no "-" sign preceding the "r" option.
Use the "u" options to replace all routines in a library that have changed since they were put into the library. You can also use the "v" option to list the names of the replaced routines. For example, to update subprograms stored in "two.f" and "four.f", type
f77 -c two.f f77 -c four.f ar uv libmysubs.aThis works only if the all routines that went into making the library are in the current directory. Otherwise, you must list the routines explicitly. For example, if routines two.o, four.o and five.o have been changed and these routines are in the current directory, then update the library by typing
ar uv libmysubs.aIf six.o is in subdirectory "sub", then type the following instead:
ar uv libmysubs.a sub/six.o
********************************************************************* * * * Correspondence to VS FORTRAN * * * ********************************************************************* * * * VS FORTRAN UNIX * * ========== ==== * * * * Creating a Subprogram Library * * ============================= * * * * txtlib gen libmy fn1 fn2.... ar crv libmysubs.a * * `lorder sub1.o sub2.o | tsort` * * * * * * Updating the Library * * ==================== * * * * txtlib del libmy sub ar rv libmysubs.a sub.o * * txtlib add libmy sub * * * * where file "sub text a" where file "sub.o" * * contains the old version of contains the new version * * the subprogram when the of the subprogram and * * "txtlib del" command is issued replaces the old version in * * and contains the revised the library "libmysubs.a". * * version when the "txtlib add" * * command is issued. * * * *********************************************************************