gfortran problem with Lion #6500

Closed
rtlee opened this Issue Jul 21, 2011 · 14 comments

8 participants

@rtlee

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.

Regards,
Todd

@Sharpie

Well, the GFortran binaries are sourced from:

http://r.research.att.com/tools

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.

@Sharpie

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

@rtlee

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

@Sharpie

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 https://raw.github.com/adamv/homebrew-alt/master/duplicates/gcc.rb --enable-fortran

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

@novocaine

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

/usr/lib/gcc/i686-apple-darwin11/4.2.1/libgcc.a
/usr/lib/gcc/i686-apple-darwin11/4.2.1/x86_64/libgcc.a

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.

@Sharpie

Allright, new GFortran binaries for Lion were released on r.research.att.com. 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 https://github.com/Sharpie/homebrew/commit/2fc0198268204b8fa164fb36e607086472bb85c9
brew uninstall gfortran
brew install gfortran

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

@rtlee

It worked -- thanks!

@Sharpie

Allright, submitted as pull request #6561.

@rtlee Thanks a bunch for testing.

@rsenk330

This worked for me too, thanks!

@janrito

Thanks for this. I was able to compile scipy thanks to this and @rsenk330's advice here: http://projects.scipy.org/scipy/ticket/1476#comment:20

@adamv

Closed by #6561

@adamv adamv closed this Jul 25, 2011
@RuiPereira

Hello,

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?

Thanks.

@Sharpie

@RuiPereira

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.

@daf

Recently had this issue trying to pip install scipy - solution was LIBRARY_PATH=/Applications/Xcode.app/Contents/Developer/usr/lib/llvm-gcc/4.2.1 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.