-2

I've installed miniconda3 gfortran and have set DYLD_FALLBACK_LIBRARY_PATH to /miniconda3/lib in .bash_profile. I've read many other answers but nothing seems to work.

gfortran --version
GNU Fortran (GCC) 4.8.5

runtime error is

dyld: Library not loaded: @rpath/libgfortran.3.dylib
  Referenced from: /Users/Liza/Desktop/family/xmas/./a.out
  Reason: image not found
Oo.oO
  • 12,464
  • 3
  • 23
  • 45
Elizabeth
  • 1
  • 1
  • 1
    Welcome, please take the [tour]. If the other questions and answers did not apply you *really* have to give us more details. How exactly did they *"not work"*? If you want a different answer, you must tell us how your case is different. Where exactly is `libgfortran.3.dylib` present on your computer? – Vladimir F Героям слава Dec 08 '20 at 15:36
  • I would be happy to answer your questions and provide more details, but in fact your reply already pointed me quickly to the problem. I had provided the incorrect path to libgfortran.3.dylib in my .bash_profile. thank you very much! Problem solved. I no longer get a runtime error. – Elizabeth Dec 08 '20 at 15:48

1 Answers1

1

One should not need to set DYLD_FALLBACK_LIBRARY_PATH in order to use a Fortran compiler in a Conda environment, especially not setting it on a user-wide level via .bash_profile.

Creating an env with the Conda Forge Fortran compiler stack:

conda create -n foo -c conda-forge fortran-compiler

one can then see on activation that the environment automatically handles updating the appropriate flags to pick up the envs/foo/lib and envs/foo/include directories:

(base) $ conda activate foo
(foo) $ env | grep -E "^(FORTRAN|LD)"
LDFLAGS=-Wl,-pie -Wl,-headerpad_max_install_names -Wl,-dead_strip_dylibs -Wl,-rpath,/Users/mfansler/miniconda3/envs/foo/lib -L/Users/mfansler/miniconda3/envs/foo/lib
LD=x86_64-apple-darwin13.4.0-ld
FORTRANFLAGS=-march=core2 -mtune=haswell -ftree-vectorize -fPIC -fstack-protector -O2 -pipe -isystem /Users/mfansler/miniconda3/envs/foo/include
LDFLAGS_LD=-pie -headerpad_max_install_names -dead_strip_dylibs -rpath /Users/mfansler/miniconda3/envs/foo/lib -L/Users/mfansler/miniconda3/envs/foo/lib

For general workflow, I would recommend creating a YAML file that includes all the dependencies you require, e.g.,

fortran-env.yaml

channels:
  - conda-forge
  - defaults
dependencies:
  - fortran-compiler
  - zlib  # example dependency

Then create an environment from this (conda env create -f fortran-env.yaml), which you activate when compiling your project.

merv
  • 67,214
  • 13
  • 180
  • 245