Enzo: ~ld: library not found for -lgfortran~

If you're working with Enzo for cosmological simulations on a darwin machine trying to use the Make.mach.darwin make file, you'll probably run into a ld: library not found for -lgfortran error. If you're running homebrew, it'll give you a:

→ brew install gfortran
Error: No available formula with the name "gfortran"
GNU Fortran is now provided as part of GCC, and can be installed with:
brew install gcc

which doesn't really solve the issue if you've already got GCC installed. The problem occurs because there's no easy way to test for directories in a makefile without doing something really hacky, so the enzo devs have just decided to leave it as is, and enzo can't find your gfortran installation. You'll want to scroll down to line 128 in the Make.mach.darwin file (Enzo 2.5), and change the line

`LOCAL_LIBS_MACH   = -L$(LOCAL_FC_INSTALL)/lib -lgfortran `


`LOCAL_LIBS_MACH   = -L$(LOCAL_FC_INSTALL)/lib/gcc/i686-apple-darwin11/4.2.1 -lgfortran`

Your GCC version will vary depending which version you're on, just change it as appropriate.

If you're not using homebrew (or you're opposed to linking it using GCC's gfortran version), go grab a binary from GCC, make sure you've got the prereqs filled, and install it into /usr/local. Then just change the same line to:

`LOCAL_LIBS_MACH   = -L$(LOCAL_FC_INSTALL)/gfortran/lib/i386 -lgfortran`
Posted: 2016-03-09
Filed Under: math, computer