Discussion:
g77 on Mac OS X
(too old to reply)
b***@aol.com
2005-03-01 15:24:18 UTC
Permalink
I am attempting to port several large legacy Fortran apps to Mac OS X.
The applications are perhaps 95% Fortran 77 with a few low level ANSI C
functions. The Mac is running Panther 10.3.8 with X11 installed and
with Xcode 1.5 (gcc 3.3) installed.

I installed g77 version 3.4.2 from a prebuilt binary but I do not think
that g77 installation works well with the Apple's customized gcc
installation. Each compiler seems to work well enough separately but I
can not "Make" an app that combines both .f and .c source code. A Make
calling "g77 foo1.f foo2.c" produces a series of "Non-existant
directory" warnings. There are also problems with unknown C library
functions as well as inconsistant underscore conventions.

As someone new to the GNU compiler world, should I be able to compile
and link applications built from different languages? Most commercial
products have no trouble with this but can the GCC package do it ? If
so, are there any conventions that need to be followed (other than the
obvious data type conventions) such as pragmas or compiler options?
Should I expect better results if I had built g77 instead of using a
prebuilt binary?



Thanks in advance...
b***@aol.com
2005-03-01 22:04:33 UTC
Permalink
Post by b***@aol.com
I am attempting to port several large legacy Fortran apps to Mac OS X.
The applications are perhaps 95% Fortran 77 with a few low level ANSI C
functions. The Mac is running Panther 10.3.8 with X11 installed and
with Xcode 1.5 (gcc 3.3) installed.
Alternatives to g77 are g95 and gfortran .

There are numerous users of g95 http://www.g95.org, a Fortran 95
compiler, on Mac OS X . Fortran 95 is almost a superset of Fortran 77,
and g95 has been used to compile legacy Fortran codes. Gfortran, which
is part of gcc (replacing g77), is another Fortran 95 compiler that can
be run on OS X -- see http://gfortran.org/cgi-bin/wiki.pl/MacOsX . Both
g95 and gfortran are currently being developed.
2005-03-01 23:17:14 UTC
Permalink
I considered both g95 and gfortran but decided (right or wrong) that neither
was "stable" enough for my project. I just need to get the apps ported,
running and verified without having to worry too much about compiler bugs.
g77 should be fine for what I need to do, **IF** I can get it configured
properly to work with Xcode/gcc. The suggestion to try g95 might prove
both interesting and informative however, plus there certainly are more
people actively working with g95.
Post by b***@aol.com
Post by b***@aol.com
I am attempting to port several large legacy Fortran apps to Mac OS
X.
Post by b***@aol.com
The applications are perhaps 95% Fortran 77 with a few low level ANSI
C
Post by b***@aol.com
functions. The Mac is running Panther 10.3.8 with X11 installed and
with Xcode 1.5 (gcc 3.3) installed.
Alternatives to g77 are g95 and gfortran .
There are numerous users of g95 http://www.g95.org, a Fortran 95
compiler, on Mac OS X . Fortran 95 is almost a superset of Fortran 77,
and g95 has been used to compile legacy Fortran codes. Gfortran, which
is part of gcc (replacing g77), is another Fortran 95 compiler that can
be run on OS X -- see http://gfortran.org/cgi-bin/wiki.pl/MacOsX . Both
g95 and gfortran are currently being developed.
Alan Gauld
2005-03-01 22:58:15 UTC
Permalink
Post by b***@aol.com
I installed g77 version 3.4.2 from a prebuilt binary but I do not think
that g77 installation works well with the Apple's customized gcc
installation. Each compiler seems to work well enough separately but I
can not "Make" an app that combines both .f and .c source code. A Make
calling "g77 foo1.f foo2.c"
I've done multi lingual programming with GNU but not on a Mac...

But I think you will need to compile the files separately into .o
files using the -c flag

g77 -c foo.f
gcc -c bar.c
gcc -o foobar foo.o bar.o

And I have no idea which libraries you would need to link with.
Post by b***@aol.com
As someone new to the GNU compiler world, should I be able to compile
and link applications built from different languages?
Yes but not using the same compiler to compile both files in one
go.
Post by b***@aol.com
Should I expect better results if I had built g77 instead of using a
prebuilt binary?
That might be necessary but I wouldn't expect so provided the
basic gccc versions were the same. But if Apple's tweaks are
significant it might be a good idea.

Alan G.
Author of the Learn to Program website
http://www.freenetpages.co.uk/hp/alan.gauld
Dave Seaman
2005-03-01 23:54:51 UTC
Permalink
Post by Alan Gauld
Post by b***@aol.com
I installed g77 version 3.4.2 from a prebuilt binary but I do not think
that g77 installation works well with the Apple's customized gcc
installation. Each compiler seems to work well enough separately but I
can not "Make" an app that combines both .f and .c source code. A Make
calling "g77 foo1.f foo2.c"
I've done multi lingual programming with GNU but not on a Mac...
But I think you will need to compile the files separately into .o
files using the -c flag
g77 -c foo.f
gcc -c bar.c
gcc -o foobar foo.o bar.o
And I have no idea which libraries you would need to link with.
As with many Unix systems, you will need to append an underscore to the
name of any C function that is intended to be Fortran-callable. I can
verify that this works, using either gcc or g77 under OS X to perform the
link step after all the files have been compiled.
Post by Alan Gauld
Post by b***@aol.com
As someone new to the GNU compiler world, should I be able to compile
and link applications built from different languages?
Yes but not using the same compiler to compile both files in one
go.
Post by b***@aol.com
Should I expect better results if I had built g77 instead of using a
prebuilt binary?
I used g77 built from fink.
--
Dave Seaman
Judge Yohn's mistakes revealed in Mumia Abu-Jamal ruling.
<http://www.commoncouragepress.com/index.cfm?action=book&bookid=228>
2005-03-02 15:34:09 UTC
Permalink
On Solaris systems, Sun's Fortran compiler supports a pragma based solution
something like:

C#pragma C(foo1,foo2,foo3)
.....
Call foo1 (arg1,arg2)

where foo1, foo2 & foo3 are separately compiled C functions to be linked
with the Fortran code. This eliminates the need to explicitly include
underscores on the C function declarations. Does g77 support something
similar ?
Post by Dave Seaman
Post by Alan Gauld
Post by b***@aol.com
I installed g77 version 3.4.2 from a prebuilt binary but I do not think
that g77 installation works well with the Apple's customized gcc
installation. Each compiler seems to work well enough separately but I
can not "Make" an app that combines both .f and .c source code. A Make
calling "g77 foo1.f foo2.c"
I've done multi lingual programming with GNU but not on a Mac...
But I think you will need to compile the files separately into .o
files using the -c flag
g77 -c foo.f
gcc -c bar.c
gcc -o foobar foo.o bar.o
And I have no idea which libraries you would need to link with.
As with many Unix systems, you will need to append an underscore to the
name of any C function that is intended to be Fortran-callable. I can
verify that this works, using either gcc or g77 under OS X to perform the
link step after all the files have been compiled.
Post by Alan Gauld
Post by b***@aol.com
As someone new to the GNU compiler world, should I be able to compile
and link applications built from different languages?
Yes but not using the same compiler to compile both files in one
go.
Post by b***@aol.com
Should I expect better results if I had built g77 instead of using a
prebuilt binary?
I used g77 built from fink.
--
Dave Seaman
Judge Yohn's mistakes revealed in Mumia Abu-Jamal ruling.
<http://www.commoncouragepress.com/index.cfm?action=book&bookid=228>
Loading...