3

I am trying to build a Rust app and I get the below when trying to build. This happened after I installed ndarray-linalg and ndarray.

I installed gcc and openvc. I am on macOS.

 = note: ld: library not found for -lgfortran
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

How do I resolve this?

which gfortran
/usr/local/bin/gfortran

I found the library here:

ls /usr/local/Cellar/gcc/8.2.0/lib/gcc/8/libgfortran.*
/usr/local/Cellar/gcc/8.2.0/lib/gcc/8/libgfortran.5.dylib    
/usr/local/Cellar/gcc/8.2.0/lib/gcc/8/libgfortran.dylib
/usr/local/Cellar/gcc/8.2.0/lib/gcc/8/libgfortran.a      
/usr/local/Cellar/gcc/8.2.0/lib/gcc/8/libgfortran.spec
ldconfig -p | grep fortran
-bash: ldconfig: command not found

And also ran the below:

brew reinstall gcc

How can I make sure Rust will find it?

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
Tampa
  • 75,446
  • 119
  • 278
  • 425
  • 1
    binary != library – Stargateur Jan 11 '19 at 01:17
  • The linker is looking for the libgfortran library, not the gfortran executable. – molbdnilo Jan 11 '19 at 01:18
  • 1
    (I hope this works on mac as well) type `ldconfig -p | grep fortran` and put it into your question please. – hellow Jan 11 '19 at 07:03
  • @hellow I added – Tampa Jan 11 '19 at 14:51
  • I believe your question is answered by the answers of [Linking Rust application with a dynamic library not in the runtime linker search path](https://stackoverflow.com/q/40602708/155423). If you disagree, please [edit] your question to explain the differences. Otherwise, we can mark this question as already answered. – Shepmaster Jan 13 '19 at 18:58
  • 1
    Possible duplicate of [Linking Rust application with a dynamic library not in the runtime linker search path](https://stackoverflow.com/questions/40602708/linking-rust-application-with-a-dynamic-library-not-in-the-runtime-linker-search) – Denys Séguret Jan 22 '19 at 16:49

1 Answers1

0

Check first if any of the env variables are set

  • DYLD_LIBRARY_PATH
  • DYLD_FALLBACK_LIBRARY_PATH

These variables tell the compiler where to look for libraries installed on the system. Built-in libraries are usually placed in /usr/lib, and homebrew places them in /usr/local/lib. So these should be in your lib path.

If for some reason you cant find your library there you can try

export DYLD_LIBARY_PATH=$DYLD_LIBARY_PATH:/usr/local/Cellar/gcc/8.2.0/lib/gcc/8

and if that does not work try with the other variables.

patriques
  • 5,057
  • 8
  • 38
  • 48