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.

Elizabeth Haker
  • 301
  • 2
  • 3

5 Answers5

49

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

brew upgrade gawk
Utpal Kumar
  • 787
  • 5
  • 9
  • This worked for me while running into issues using make_standalone_toolchain.sh to generate an Android toolchain. – koush Oct 24 '18 at 07:07
  • 1
    It worked for me too. Just do "brew install gawk" if you haven't installed gawk yet. – yoshi Nov 11 '18 at 04:27
  • 1
    Unfortunately, simply doing this didn't do it for me. Will report back if I learn more. – Joe Germuska May 08 '19 at 14:58
  • 1
    Are there any updates? I tried upgrading gawk to no avail. Would rather not resolve with a symlink. – gdavtor Dec 18 '19 at 21:51
5

I solved it like this.

ln -s /usr/local/opt/mpfr/lib/libmpfr.6.dylib /usr/local/opt/mpfr/lib/libmpfr.4.dylib
neosarchizo
  • 558
  • 5
  • 16
  • 1
    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. – vinc17 May 07 '18 at 11:07
  • 3
    This is totally incorrect for the reasons @vinc17 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. – Brett Hale May 19 '18 at 09:43
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.

Nicholas Hamilton
  • 8,709
  • 5
  • 47
  • 75
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.

vinc17
  • 2,320
  • 10
  • 20
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.
NaN
  • 5,040
  • 4
  • 27
  • 46
roidinev
  • 1
  • 1
  • 1