Re: Installing g95 on OS X

From: Gordon Sande (g.sande_at_worldnet.att.net)
Date: 10/19/04


Date: Tue, 19 Oct 2004 17:50:41 GMT


*** Hendrickson wrote:
> Does anybody besides me see a problem here? *nix systems
> are apparently unusable by people with normal computer
> skills! This stuff is complicated beyond words. Jason
> gives a seven step program (with an error that's even
> obvious to me!) and Dave write a couple hundred lines
> of explanation/correction/improvements. And I see there
> are 3 or 4 follow-ups to his post.
>
> Maybe I just need another cup of coffee, but after 20+
> years of unix development(?), why is it so hard to
> install a $%^&ing compiler?

Good question!

I followed the recipe given for gfortran and found

0. I can only sudo fink ... from my admin account and not my
    user account. Probably a good thing in the large except
    I though the sudo/password fuss was intended to avoid
    the the extra fuss.

1. I needed to fiddle a low level file because FINK was
    not set to use UNSTABLE packages "out of the box".
    The fix was in the FAQ under "Why doesn't it work"!
    And there was some sort of problem with the path
    settings for fink so it was /sw/bin/fink instead of
    just fink.

2. The results have some sort of conflict between the Apple's
    supplied X11 and the older do-it-yourself X11. The fixes
    suggested in the diagnostics appear to do nothing. Why
    does a compiler require X11? Why does having the Apple
    supplied Aqua compatible X11 grind things to a halt?
    (I am sure that if I wanted to be a full time sysadmin
    the answer would be interesting but ...). Apple's slick
    X11 arrived circa Os X.3 and the fink scripts are probably
    older so I will have to wait for the fixes to work their way
    through the system.

So now I do not have gfortran and I am reinforced in the notion
that if and only if I fiddled full with Unix/Open Software/etc
would I be able to get it to work. I will leave the explanation
of why a compiler needs X11 as one of the great mysteries of the
universe. It is clear that fink has a lot of ingenuity behind it
as does gfortran, but at the end of the session all I have is a
lot of wasted disk space that I may get around to clearing out.

> *** (needs a Gin & Tonic) Hendrickson
>
> Dave Seaman wrote:
>
>> On Tue, 19 Oct 2004 00:10:25 GMT, Jason Nielsen wrote:
>>
>>
>>
>>>> On 18 Oct 2004 15:05:34 -0700, Nat wrote:
>>>>
>>>>> Hi, I'm attempting to install g95 on OS X (Jaguar), but being a
>>>>> complete Darwin newbie, I really don't understand the instructions
>>>>> that go with it. What does it mean by saying "G95 and friends expect
>>>>> to live under /tmp/g95"? Does that mean I have to move files around
>>>>> into some new directory that I've created? Can I do this in the GUI?
>>>>> I'm actually quite scared of poking around in Darwin because I was
>>>>> once told that I could completely wreck it if I didn't know what I was
>>>>> doing...
>>
>>
>>
>>
>>> To get the g95 binary working do the following:
>>
>>
>>
>>> 1) Download g95-powerpc-osx.tgz and put it in /tmp
>>
>>
>>
>>> 2) type: su
>>
>>
>>
>>> in a shell, it will ask you for the admin password.. type it in.
>>
>>
>>
>> That won't work unless you have gone to the trouble of enabling root
>> logins, a procedure that is definitely not recommended on the Mac. For
>> one thing, it's rather difficult to undo, once done.
>>
>> Instead of 'su' you should use a command like
>>
>> sudo bash
>>
>> where you may substitute your favorite shell for 'bash', if desired. You
>> will be asked for your account password. You must be running under an
>> account that has admin privileges for this to work.
>>
>> From here on until you type 'exit' you will see '#' as your prompt, which
>> is a reminder that you are running with root privileges and therefore you
>> should carefully verify each command you type before you press <return>.
>>
>>
>>> 3) type: cd /tmp
>>
>>
>>
>>> 4) type: tar -zxf g95-powerpc-osx.tgz
>>
>>
>>
>> This is not quite what the INSTALL file recommends. I suggest using the
>> following instead:
>>
>> 3) cd /usr/local
>> 4) tar -zxf /tmp/g95-powerpc-osx.tgz
>>
>> and then type the following (this is between steps 4 and 5):
>>
>> ln -s /usr/local/g95-install /tmp/g95
>>
>>
>>> 5) type: ln -s /tmp/g95-install/bin/powerpc-apple-darwin6.8-g95
>>> /usr/local/bin/g95
>>
>>
>>
>>> all this in one line. It makes a link from /usr/local/bin/g95 to the
>>> compiler binary in /tmp/ so you can just type g95 to compile something.
>>
>>
>>
>> First you should make sure the directory /usr/local/bin exists. It
>> doesn't on a stock Macintosh:
>>
>> mkdir -p /usr/local/bin
>>
>> Next, you should modify the command 5) to specify a path beginning with
>> /usr/local in place of /tmp:
>>
>> 5) ln -s /usr/local/g95-install/bin/powerpc-apple-darwin6.8-g95
>> /usr/local/bin/g95
>>
>> That's supposed to be all on one line.
>>
>>
>>> 5) type: exit
>>
>>
>>
>> After this you are no longer running with root privileges.
>>
>>
>>
>>> 6) type: g95 -c myprog.f90
>>
>>
>>
>> Assuming you have a fortran program in the file myprog.f90 in your
>> current directory. If you see a response like "g95: command not found"
>> at this point, it means you need to add /usr/local/bin to your PATH. The
>> exact method for doing that depends on your shell. If you are using
>> bash, you can add the line
>>
>> export PATH=/usr/local/bin:$PATH
>>
>> to the file .bash_profile in your home directory (or create a new file by
>> that name if it doesn't exist). From that point on, each new Terminal
>> window that you open will have your PATH initialized so that g95 can be
>> found.
>>
>>
>>> where myprog.f90 is some simple program (make sure you are in the
>>> directory where the program lives). If it produces an a.out file you
>>> are golden. If it doesn't let me know and it means that
>>> /usr/local/bin isn't in your path... if that is the case which I
>>> doubt e-mail again and I'll give you directions (/usr/local/bin is a
>>> pretty standard dir for a user account on *NIX machines and should be
>>> in your path by default).
>>
>>
>>
>>> The reason why you should untar the file in /tmp is that the compiler
>>> thinks all its important libraries are there so it can link them at
>>> compile time. If you don't put it in /tmp you will have to tell the
>>> compiler where they are using environmental variables.. so my
>>> suggestion is to simply use /tmp... when the compiler is complete I'm
>>> sure a better directory will be chosen.
>>
>>
>>
>> I don't see how you can count on /tmp/g95-install staying put after the
>> next reboot. I installed in /usr/local/g95-install and then placed a
>> symbolic link in /tmp, as described in the INSTALL file. It works fine.
>>
>>
>