gfortran problem with Lion #6500

rtlee opened this Issue Jul 21, 2011 · 14 comments

8 participants


I'm getting an error with gfortran on a freshly installed Lion computer. The error is:

ld: library not found for -lgcc

I appreciate anyone who can offer some insights.



Well, the GFortran binaries are sourced from:

The latest binary was built against XCode 3.2.3, but works for 3.2.5 and 3.2.6. I cannot guarantee that it will work with XCode 4.0+.

I don't know if much can be done about this until Lion deployment becomes more wide-spread and open source projects publish needed updates.


Actually, are the other GCC compilers from XCode still working?


Yes, the version of GCC with XCode 4.1 works fine. It's just gfortran that's the problem.


Hmm... not sure what to do then. I can shoot Simon Urbanek an email and see if he's aware of the issue.

I won't really be able to dig into testing this until I upgrade to Lion---which won't be for a month or two as I prefer to let the dust settle a bit before adopting a major release.

As an alternative, you could install the GCC brew from Homebrew-alt and tell it to build you a fortran compiler:

brew install --enable-fortran

The resulting binary is named gfortran-4.6 to avoid clashing with other copies of GCC.


hey, I'm having the same problem on 10.7.

apple moved libgcc.a which gfortran is trying to link into binaries it produces.

find /usr/lib -name 'libgcc.a' gives


in 10.6 its in the same place but with darwin10.

so the obvious quick hack is to do export LIBRARY_PATH=/usr/lib/gcc/i686-apple-darwin11/4.2.1 and try again.

that seems to work for me - the linker didn't complain and this was enough to successfully complete a scipy build via pip - and pass all the tests - but I can see that the libgcc.a is a different size in the two versions so YMMV.


Allright, new GFortran binaries for Lion were released on I just updated the formula, but I need a couple of Guinea Pigs to test it out as I don't have a machine running 10.7 myself.

To try the formula, do:

cd `brew --prefix`
git checkout -b gfortran-test
brew pull
brew uninstall gfortran
brew install gfortran

Let me know if it works or if anything goes wrong.


It worked -- thanks!


Allright, submitted as pull request #6561.

@rtlee Thanks a bunch for testing.


This worked for me too, thanks!


Thanks for this. I was able to compile scipy thanks to this and @rsenk330's advice here:


Closed by #6561

@adamv adamv closed this Jul 25, 2011


I was having problems compiling numpy+atlas/lapack+gfortran until I found out that the libgfortran.a linked by this formula is the i386 one, instead of the x86_64 under Cellar/gfortran/4.2.4-5666.3/lib/gcc/i686-apple-darwin11/4.2.1/x86_64.

Would it be possible to have an install option or test in some way the arch of the system before linking?




GFortran should choose which libgfortran.a file gets linked based on the -arch flags that get passed to the compiler. I suspect numpy may be forcing an i386 build---the Python guys like to do that as wxWidgets is i386 only and a lot of Python modules use wxPython.


Recently had this issue trying to pip install scipy - solution was LIBRARY_PATH=/Applications/ pip install scipy. Just in case anyone else is looking.

@xu-cheng xu-cheng locked and limited conversation to collaborators Feb 16, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.