Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GCC and gfortran... How are they related?

Status
Not open for further replies.

NickFort

Technical User
Jun 10, 2010
113
Hi all,

I'm pretty new to Fortran (only dabbled in it a bit last year), but Google isn't terribly forthcoming with answers. I'm sure I'll be posting plenty of questions here, but my first one isn't related to programming, as such.

How are GCC and gfortran related? I ask this, because on where I got gfortran, there are a number of offers for Windows binaries, and the MinGW build is suggested. There are four bullets in that section; one of these leads to and the other to
Here's where my confusion comes in. I installed the former, and it comes with g++, gcc and g77. Now, as far as I can gather, the only way those can compile Fortran is with g77, and only Fortran 77 at that. I, however, am dealing with F95. The second link I gave is an installer which installs gfortran, and can compile F95 as well as F77, and probably most/all of the older versions. Those two installers appear to install completely different compilers.

So, why does the gfortran page point to MinGW, when -- as far as I can see -- gfortran isn't included in it? How is GCC related to gfortran?

Thanks!

N.F.

--------------------------------------
Background: Chemical engineer, familiar mostly with MATLAB, but now branching out into real programming.
 
Gfortran is the Fortran compiler front end and run-time libraries for gcc (see Gfortran should be the successor of g77.

My situation is similar with your. Some times ago I installed MSYS and MinGW and found only g77 included. To compile Fortran 90/95 I installed g95 and gfortran separately - and it works: Now I have all 3 compilers available (g95 installs in MingW subdirectory and gfortran separately in c:\Program Files)

In the link above you can read, that "GNU Fortran is developed on the mainline of GCC and has been part of the compiler collection since the 4.0.0 release"

In my installation of MinGW I see, that
Code:
$ gcc --version
gcc.exe (GCC) 3.4.5 (mingw-vista special r3)
...
So, because I have only gcc version 3.x, the gfortran compiler was not included in the installation.
What gcc version you have in your actual MingW installation? I thing you will have only gcc 3.x too...
 
Thanks for the reply, mikrom. Your answer made perfect sense... until I checked my version. My version output is:

Code:
gcc (GCC) 4.6.0 20100524 (experimental) [trunk revision 159774]

Has MinGW decided to remove gfortran without the gfortran folks knowing about it?

--------------------------------------
Background: Chemical engineer, familiar mostly with MATLAB, but now branching out into real programming.
 
I'm astonished: if you have gcc 4.x then I don't understand why it comes with g77 and not gfortran...?
Probably is something wrong with Mingw...?
IMHO, you have 2 choices:
1. try to install gfortran and/or g95 separately
2. or if you want to have unix like environment then try to use cygwin[/cygwin]
Maybe, in cygwin gcc 4.x comes packaged with with gfortran and not g77 (but I'm not sure).
But be aware about diffeneces between MSYS/MinGW and Cygwin:
With MingW gcc/gfortran you create windows native executable (exe).
With cygwin gcc/gfortran you don't create exe, so your binary needs to run in cygwin environment.
 
I can't imagine why the Windows binary wouldn't contain the gfortran -- especially when the gfortran site lists the MinGW build under the Windows binaries. Either way, I do have gfortran working (from the second link), but I was hoping to find out where the inconsistency was, or rather, what I was missing in the whole thing.

That's one thing that annoys me about open source software: there's no "contact" link anywhere, just obscure mailing lists.

Anyway, thanks again for your help, mikrom. If you get any other ideas as to why this is, please let me know, but we may never find out...

--------------------------------------
Background: Chemical engineer, familiar mostly with MATLAB, but now branching out into real programming.
 
Actually, I'm wondering if it doesn't have something to do with the "automated installer" I used from That's the only one that made sense to use, but I see that does have libgfortran in it.

Hmmm... Did the installer not download/install gfortran, I wonder? In the "Select components to install", I ticked "runtime", "runtime" (yes, there are two; no idea why!), "w32api", "binutils" and "MinGW Make". I left unticked "Ada Compiler" and "Java Compiler", because they didn't seem relevant.

--------------------------------------
Background: Chemical engineer, familiar mostly with MATLAB, but now branching out into real programming.
 
Hi NickFort,
You are right: the problem is with the MinGW installer. I found this info:
"The automated installer is now considered deprecated, and is currently unmaintained; it will not install GCC 4. You will get GCC 3 using this method. If you want to install the latest GCC release, use the Manual Installation method below."
read more here:

In the section Manual Installation you can find this advice:
"Optionally you may want to add any of the following additional languages ....
...
gcc-gfortran (bin and dll) for Fortran 90/95
...
"
 
Ah-ha! OK, now it's becoming clearer. The only thing that doesn't make sense is how I wound up with GCC 4.6.0 with the automated installer given "You will get GCC 3 using this method", but maybe it's been changed slightly to point to the latest version or something. But, to be frank, this is a good enough explanation for me!

Thanks for all your help with this, mikrom!

--------------------------------------
Background: Chemical engineer, familiar mostly with MATLAB, but now branching out into real programming.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top