altmany / export_fig

A MATLAB toolbox for exporting publication quality figures
BSD 3-Clause "New" or "Revised" License
1.27k stars 365 forks source link

Pdftops error on MacBook Pro M1 #355

Closed abbiekressner closed 2 years ago

abbiekressner commented 2 years ago

I am trying to install export_fig on my MacBook Pro (Apple M1 Pro) without success. I have used export_fig for many years and really rely on it, so I hope this issue can be solved.

I receive the 'Pdftops error' when I try to save a figure as *.eps, and based on the suggestions, I have tried to follow the details in Issue #137. /usr/local/lib/libfreetype.6.dylib did not exist for me so instead I used the following.

sudo scp /opt/homebrew/Cellar/freetype/2.12.0/lib/libfreetyp
e.6.dylib /Applications/MATLAB_R2021b.app/bin/maci64/libfreetype.6.dylib

When I then try to open Matlab, I get the following error:

Caught "std::exception" Exception message is:
Error loading /Applications/MATLAB_R2021b.app/bin/maci64/builtins/matlab_graphics_hg/mwhg_builtinimpl.dylib. dlopen(/Applications/MATLAB_R2021b.app/bin/maci64/builtins/matlab_graphics_hg/mwhg_builtinimpl.dylib, 0x000A): Library not loaded: @rpath/libfreetype.6.dylib
  Referenced from: /Applications/MATLAB_R2021b.app/bin/maci64/libpodofo.0.9.6.dylib
  Reason: tried: '/Applications/MATLAB_R2021b.app/bin/maci64/libfreetype.6.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/Applications/MATLAB_R2021b.app/bin/maci64/./libfreetype.6.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/Applications/MATLAB_R2021b.app/bin/maci64/../../sys/os/maci64/libfreetype.6.dylib' (no such file), '/Applications/MATLAB_R2021b.app/bin/maci64/libfreetype.6.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/Applications/MATLAB_R2021b.app/bin/maci64/./libfreetype.6.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/Applications/MATLAB_R2021b.app/bin/maci64/../../sys/os/maci64/libfreetype.6.dylib' (no such file), '/Applications/MATLAB_R2021b.app/bin/maci64/builtins/matlab_graphics_hg/libfreetype.6.dylib' (no such file), '/Applications/MATLAB_R2021b.app/bin/maci64/builtins/matlab_graphics_hg/./libfreetype.6.dylib' (no such file), '/Applications/MATLAB_R2021b.app/bin/maci64/builtins/matlab_graphics_hg/../../../../bin/maci64/libfreetype.6.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/Applications/MATLAB_R2021b.app/bin/maci64/builtins/matlab_graphics_hg/../../../../sys/os/maci64/libfreetype.6.dylib' (no such file), '/Applications/MATLAB_R2021b.app/bin/maci64/builtins/matlab_graphics_hg/libfreetype.6.dylib' (no such file), '/Applications/MATLAB_R2021b.app/bin/maci64/builtins/matlab_graphics_hg/./libfreetype.6.dylib' (no such file), '/Applications/MATLAB_R2021b.app/bin/maci64/builtins/matlab_graphics_hg/../../../../bin/maci64/libfreetype.6.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/Applications/MATLAB_R2021b.app/bin/maci64/builtins/matlab_graphics_hg/../../../../sys/os/maci64/libfreetype.6.dylib' (no such file), '$ORIGIN:/libfreetype.6.dylib' (no such file), '/Applications/MATLAB_R2021b.app/bin/maci64/./libfreetype.6.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/Applications/MATLAB_R2021b.app/Contents/MacOS/libfreetype.6.dylib' (no such file), '/Applications/MATLAB_R2021b.app/Contents/MacOS/./libfreetype.6.dylib' (no such file), '/Applications/MATLAB_R2021b.app/Contents/MacOS/../../standalone/bin/maci64/libfreetype.6.dylib' (no such file), '/Applications/MATLAB_R2021b.app/Contents/MacOS/../../sys/os/maci64/libfreetype.6.dylib' (no such file), '/Applications/MATLAB_R2021b.app/Contents/MacOS/../../bin/maci64/libfreetype.6.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/local/lib/libfreetype.6.dylib' (no such file), '/usr/lib/libfreetype.6.dylib' (no such file): No such file or directory: No such file or directory
Error occurred during background graphics initialization: Error loading /Applications/MATLAB_R2021b.app/bin/maci64/builtins/matlab_graphics_hg/mwhg_builtinimpl.dylib.
dlopen(/Applications/MATLAB_R2021b.app/bin/maci64/builtins/matlab_graphics_hg/mwhg_builtinimpl.dylib, 0x000A): Library not loaded: @rpath/libfreetype.6.dylib
  Referenced from: /Applications/MATLAB_R2021b.app/bin/maci64/libpodofo.0.9.6.dylib
  Reason: tried: '/Applications/MATLAB_R2021b.app/bin/maci64/libfreetype.6.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')),
  '/Applications/MATLAB_R2021b.app/bin/maci64/./libfreetype.6.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')),
  '/Applications/MATLAB_R2021b.app/bin/maci64/../../sys/os/maci64/libfreetype.6.dylib' (no such file), '/Applications/MATLAB_R2021b.app/bin/maci64/libfreetype.6.dylib' (mach-o
  file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/Applications/MATLAB_R2021b.app/bin/maci64/./libfreetype.6.dylib' (mach-o file, but is an incompatible
  architecture (have 'arm64', need 'x86_64')), '/Applications/MATLAB_R2021b.app/bin/maci64/../../sys/os/maci64/libfreetype.6.dylib' (no such file),
  '/Applications/MATLAB_R2021b.app/bin/maci64/builtins/matlab_graphics_hg/libfreetype.6.dylib' (no such file),
  '/Applications/MATLAB_R2021b.app/bin/maci64/builtins/matlab_graphics_hg/./libfreetype.6.dylib' (no such file),
  '/Applications/MATLAB_R2021b.app/bin/maci64/builtins/matlab_graphics_hg/../../../../bin/maci64/libfreetype.6.dylib' (mach-o file, but is an incompatible architecture (have
  'arm64', need 'x86_64')), '/Applications/MATLAB_R2021b.app/bin/maci64/builtins/matlab_graphics_hg/../../../../sys/os/maci64/libfreetype.6.dylib' (no such file),
  '/Applications/MATLAB_R2021b.app/bin/maci64/builtins/matlab_graphics_hg/libfreetype.6.dylib' (no such file),
  '/Applications/MATLAB_R2021b.app/bin/maci64/builtins/matlab_graphics_hg/./libfreetype.6.dylib' (no such file),
  '/Applications/MATLAB_R2021b.app/bin/maci64/builtins/matlab_graphics_hg/../../../../bin/maci64/libfreetype.6.dylib' (mach-o file, but is an incompatible architecture (have
  'arm64', need 'x86_64')), '/Applications/MATLAB_R2021b.app/bin/maci64/builtins/matlab_graphics_hg/../../../../sys/os/maci64/libfreetype.6.dylib' (no such file),
  '$ORIGIN:/libfreetype.6.dylib' (no such file), '/Applications/MATLAB_R2021b.app/bin/maci64/./libfreetype.6.dylib' (mach-o file, but is an incompatible architecture (have
  'arm64', need 'x86_64')), '/Applications/MATLAB_R2021b.app/Contents/MacOS/libfreetype.6.dylib' (no such file),
  '/Applications/MATLAB_R2021b.app/Contents/MacOS/./libfreetype.6.dylib' (no such file),
  '/Applications/MATLAB_R2021b.app/Contents/MacOS/../../standalone/bin/maci64/libfreetype.6.dylib' (no such file),
  '/Applications/MATLAB_R2021b.app/Contents/MacOS/../../sys/os/maci64/libfreetype.6.dylib' (no such file),
  '/Applications/MATLAB_R2021b.app/Contents/MacOS/../../bin/maci64/libfreetype.6.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')),
  '/usr/local/lib/libfreetype.6.dylib' (no such file), '/usr/lib/libfreetype.6.dylib' (no such file): No such file or directory: No such file or directory

Have I done something wrong or is this related to the M1 architecture?

altmany commented 2 years ago

As far as I can tell, this is due to the fact that you are using an Intel-based Mac but the FreeType lib you're trying to use is based on the Arm64 architecture, which is incompatible. Try to reinstall pdftops from the Mac 64-bits download link here: https://www.xpdfreader.com/download.html (or just the FreeType lib from the link at the bottom of that page).