dyld: Library not loaded: /usr/local/lib/libmpfr.4.dylib
Asked Answered
C

5

20

When I run "make" on a project I get this error:

dyld: Library not loaded: /usr/local/lib/libmpfr.4.dylib 
Referenced from: /Users/Petrov/Downloads/mips/bin/../libexec/gcc/mipsel-elf/4.8.1/cc1
  Reason: image not found

There is no libmpfr.4.dylib file in /usr/local/lib, but there is libmpfr.6.dylib. I have mpfr 4.0.1 installed. I have tried reinstalling Xcode and mpfr already.

Comfy answered 23/3, 2018 at 20:23 Comment(4)
have you fixed the problem ? i have the same problem tooSicyon
Sorry I still haven't fixed itComfy
i've fixed that with symlinking the libmpfr.dylib to libmpfr.4.dylib it works for me , but i dont know the future problemsSicyon
That worked. Thank you!Comfy
A
49

I had similar problem in Mac. I fixed it by upgrading the "gawk" using brew

brew upgrade gawk
Anthropomorphic answered 19/5, 2018 at 8:35 Comment(4)
This worked for me while running into issues using make_standalone_toolchain.sh to generate an Android toolchain.Selmner
It worked for me too. Just do "brew install gawk" if you haven't installed gawk yet.Pudency
Unfortunately, simply doing this didn't do it for me. Will report back if I learn more.Mcgruter
Are there any updates? I tried upgrading gawk to no avail. Would rather not resolve with a symlink.Hautesavoie
H
6

I solved it like this.

ln -s /usr/local/opt/mpfr/lib/libmpfr.6.dylib /usr/local/opt/mpfr/lib/libmpfr.4.dylib
Hanrahan answered 28/4, 2018 at 3:5 Comment(2)
This symlink is not recommended: this may yield failures (crashes or incorrect results) because the ABI of MPFR 4.0.x is incompatible with the ones of the previous MPFR versions (this is why the library version number has changed from 4 to 6). Now, AFAIK, the incompatibilities are minor and most applications are probably not affected, but I'm not sure.Akimbo
This is totally incorrect for the reasons @Akimbo mentions. On OSX, libmpfr.4.dylib corresponds to a 'mpfr-3.x' release, while libmpfr.6.dylib corresponds to a 'mpfr-4.x` release. A change in MAJOR version must be considered binary-incompatible. If it 'worked', you were just lucky.Garrote
E
3

@Vinc17 is right in his comment to @neosarchizo's proposed solutiion, symlinks can be problematic if referencing a different version, HOWEVER, in my case, running the following command:

locate libmpfr.4.dylib

Showed that I did have the right library in a different directory:

/opt/local/lib/libmpfr.4.dylib

So for me, I felt it was perfectly safe to use the symlink approach, ie:

sudo ln -s /opt/local/lib/libmpfr.4.dylib /usr/local/lib/libmpfr.4.dylib

Probably a hack, but problem solved.

Enough answered 21/6, 2018 at 8:14 Comment(0)
A
2

The cause of the error is that you have upgraded from MPFR 3.1.x to MPFR 4.0.x, which is ABI-incompatible with MPFR 3.1.x (a MPFR 4.0.x library cannot be used with a program compiled against MPFR 3.1.x). Hence the change from libmpfr.4.dylib (used for MPFR 3.0.x and MPFR 3.1.x) to libmpfr.6.dylib (used for MPFR 4.0.x at least).

What you should have done instead, in order to avoid the error, is to install MPFR 4.0.x without uninstalling libmpfr.4.dylib from MPFR 3.1.x: all new compiled software would use MPFR 4.0.x and libmpfr.6.dylib, but older binaries depending on MPFR would have still been able to run by using libmpfr.4.dylib (a possible exception is when there are two different dependencies on MPFR, via libraries, where both libmpfr.4.dylib and libmpfr.6.dylib could be needed, in which case this might not work).

Now, you should recompile Xcode. If you get Xcode already compiled (from a binary package), make sure that you get either one compiled against MPFR 4.0.x, or one that includes the libmpfr.4.dylib file. If this is not possible, you should reinstall MPFR 3.1.x. Then you should be able to install MPFR 4.0.x without removing libmpfr.4.dylib, as said above.

Akimbo answered 10/4, 2018 at 8:28 Comment(0)
T
0

Use the system toolchains to compile:

export PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:$PATH.
Tripod answered 12/4, 2019 at 7:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.