This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


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

Re: FORTRAN -- LINKING PROGRAMS


Bob Kuhn wrote:

> I just obtained G77 and got my first (4 line)
> program to work.  I have the following higher
> priority questions:
> 
> 1. I tried
>      g77 fortfile > printfile
>    I wanted to get my compiler error messages to go
>    to "printfile".  It did not work (i.e. the error
>    messages continued to go to the screen). Is there
>    an easy way to get my compiler error messages to
>    go to a file?

Depending on the "shell" you're using you could try:

g77 fortfile.f >& printfile

or:

g77 fortfile.f > printfile 2>&1

> 2. Typically when I have used for FORTRAN in the
>    past and have had large programs with many
>    subroutines, I have precompiled some of the
>    programs and link edited combining precompiled
>    subroutines with the source code of uncompiled
>    subroutines.  My guess is that this is easy to do
>    with G77 but was unable to find an example in the
>    documentation.  Basically I need two steps:
> 
>    A. How do I compile source code of a subroutine
>       to some kind of object code (rather than
>       creating an executable file)?

g77 -c your-subroutine.f

will create your-subroutine.o which contains the object code for the
routine in your-subroutine.f.

>    B. How to I link edit, combining object code from
>       multiple subroutines (possibly with the source
>       code of another subroutine) ?

You can gather the object files (xxxn.o) created with the command above
in an object library (lll.a) in this way:

ar rc lll.a xxx1.o xxx2.o ... xxxn.o

Then you could link your program as follows:

g77 -o yourprogram yourprogram.f lll.a

> 2. I have combined C and FORTRAN routines in the
>    past using the ABSOFT PC compiler.  Do you have a
>    simple example showing the link edit steps for
>    doing this with the GNU compilers?  I may which
>    to go either way (FORTRAN calling C or C calling
>    FORTRAN.)

This is all explained in the info files accompanying the g77 / gcc
distribution ...

Cheers,

-- 
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
GNU Fortran 95: http://g95.sourceforge.net/ (under construction)

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