14

I have tried many workarounds (brew upgrade/update, brew doctor, reinstalling gcc and gfortran, exporting libraries path etc.) to solve this issues, but none of them succeeded. When I try to execute a Fortran executable I get the same error message:

dyld: Library not loaded: /usr/local/gfortran/lib/libgfortran.3.dylib Referenced from: /Users/... Reason: image not found

I have read many different suggestions, is there a set of steps to follow to solve this problem?

Thank you.

More info: MacOS Mojave 10.14.5

which gcc returns /usr/bin/gcc

which gfortran returns /usr/local/bin/gfortran

3
  • have you tried installing gfortran from here? coudert.name/software/gfortran-6.3-Sierra.dmg
    – Oo.oO
    Jul 25, 2019 at 18:34
  • It is also a good idea to build it from sources (take a look here) owsiak.org/running-open-mpi-on-macos
    – Oo.oO
    Jul 25, 2019 at 18:36
  • I have tried with the .dmg installer, but I still get the same error message. I have also tried to build it from source, but I get several error messages in the Terminal (e.g. ../../gcc-5.1.0/gcc/graphite-poly.h:1092:19: error: use of undeclared identifier 'isl_space_add_dims' isl_space *d2 = isl_space_add_dims (d1, isl_dim_in, n); )
    – Roland
    Jul 26, 2019 at 13:58

3 Answers 3

13

SOLVED!

You need first to locate the library:

locate libgfortran.3.dylib 

You should get something like

/usr/local/Cellar/gcc@5/5.5.0_3/lib/gcc/5/libgfortran.3.dylib

Then you can link the library to the right folder:

ln /usr/local/Cellar/gcc@5/5.5.0_3/lib/gcc/5/libgfortran.3.dylib /usr/local/lib/libgfortran.3.dylib
1
  • 2
    Thank you so much!
    – abhikrroy
    Oct 21, 2019 at 20:52
0

I had a similar issue and I found a problem. I compiled a fortran file with

 9/libgfortran.5.dylib

I realised that in meanwhile, when I upgraded the homebrew, the updated version was

 10/libgfortran.5.dylib

Which was used when I executed the file. Repeated compilation solved the problem.

0

I had to force the version of gcc:

brew install gcc@5 

I symbollically linked

ln -s /usr/local/Cellar/gcc\@5/5.5.0_6/bin/gcc-5 /usr/local/bin/gcc
ln -s /usr/local/Cellar/gcc\@5/5.5.0_6/bin/gfortran-5 /usr/local/bin/gfortran
ln -s /usr/local/Cellar/gcc\@5/5.5.0_6/lib/gcc/5/libgfortran.3.dylib /usr/local/lib/libgfortran.3.dylib
ln -s /usr/local/Cellar/gcc\@5/5.5.0_6/lib/gcc/5/libquadmath.0.dylib /usr/local/lib/libquadmath.0.dylib

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.