Skip to content Skip to sidebar Skip to footer

How Do I Replace My Hpc Gfortran With Homebrew Gfortran?

I currently have Xcode (along with command line tools) and gfrotran from HPC installed on my Yosemite system, and would like to replace HPC's gfortran with Homebrew's (because I'm

Solution 1:

I recently worked through this very same problem. This is how I got/have it working on my Yosemite system.

Some things about home-brew and the command line tools compilers:

  1. The compiler you get through home-brew will overwrite the existing one if it is in the same place. If you have a fortran compiler that you obtained from the command line tools then it will not be affected.(Home-brew will warn you about this before doing anything)

  2. The binaries for the compilers you get through the command line tools are in /usr/bin .

  3. The compilers (and anything else) you obtain using home-brew are stored in the cellar ( /usr/local/Cellar) and the executables are linked into the directory /usr/local/bin.

What to do?

  1. Modify the path: I only needed to use the compilers I got through home-brew so I moved /usr/local/bin to the top of my $path this ensures that the /usr/local/bin directory is searched before /usr/bin.

  2. Use aliases : You can create an alias for each compiler so that you can use them interchangeably as you wish. To create an alias you will have to modify your shell-rc file. On my system I use the tcsh, and to create an alias for the home-brew compiler I would add something similar to this to my ~/.cshrc file.

    alias brewgfortran '/usr/local/bin/gfortran'

    this now executes the home-brew gfortran-4.9 executable that is stored in my cellar and linked to /usr/local/bin/gfortran/

  3. IF you absolutely want rid of the apple compilers you can of course remove them from the /usr/bin/ directory completely. I don't think this is the best idea though. I have shown you a few ways to avoid using them and if you ever needed them for some reason you would be SOL. I cant say if those tools you need will work without them as I have never used any of those, however I know it will build python packages for you (sorry hope this still helps)

NOTE: If you are not using the same shell as me the syntax for the alias is a little different (I think) just google it or man alias

Post a Comment for "How Do I Replace My Hpc Gfortran With Homebrew Gfortran?"