Converting to Latest gfortran from Mac HPC

xcode.jpg

In preparation for Leopard, I decided to see if the latest version of gfortran from the Mac HPC guys would build my thesis work. As little as about 6 months ago it wouldn't - there were issues with it that were supposedly fixed, but the build wasn't on the latest release. I stuck with g77 because it was Tiger (10.4), and it worked. But with Leopard using gfortran and no g77 port, it seemed like a good idea to get the latest gfortran and give it a try.

Interestingly, when I compiled it it compiled cleanly, but on linking I got the following:

    /usr/bin/ld: warning can't open dynamic library: /libgcc_s.1.dylib referenced
    from: /usr/local/lib/gcc/i386-apple-darwin8.10.1/4.3.0/../../../libgfortran.dylib
    (checking for undefined symbols may be affected) (No such file or directory,
    errno = 2)

I did a little searching and found that the solution was to change the 'install_name' (refer to a previous post about Xcode 2.4+ needing this) from /libgcc_s.1.dylib to something like where it's really located: /usr/local/lib/libgcc_s.1.dylib.

To do this simply go into /usr/local/lib and type:

    sudo install_name_tool -change /libgcc_s.1.dylib /usr/local/lib/libgcc_s.1.dylib
      libgfortran.3.dylib

(all one line). With this, the linking problem disappears and the code runs great. Now I know that I don't need g77 on Leopard. Nice. All we're doing is changing the 'install_name' in the gfortran library to have the complete path name as opposed to the simply leading '/'. Nice little tool to have around when issues like this come up.