Mac OS X: Plotting with GNU Octave (libfreetype)

For our courses in linear algebra, we are using the GNU Octave software for numerical computation. Since I am using a MacBook Air for university, I had to install Octave on Mac OS X. I simply followed the steps described here and successfully installed gnuplot and the Octave software package. But when I tried to plot something with Octave, I received the following error message:

dyld: Library not loaded: /usr/X11/lib/libfreetype.6.dylib
  Referenced from: /usr/X11/lib/libfontconfig.1.dylib
  Reason: Incompatible library version: libfontconfig.1.dylib requires version 14.0.0 or later, but libfreetype.6.dylib provides version 13.0.0
dyld: Library not loaded: /usr/X11/lib/libfreetype.6.dylib
  Referenced from: /usr/X11/lib/libfontconfig.1.dylib
  Reason: Incompatible library version: libfontconfig.1.dylib requires version 14.0.0 or later, but libfreetype.6.dylib provides version 13.0.0
[..]

Obviously, there is some kind of versioning problem with libfreetype. So a quick search returned a thread on StackOverflow, where you find the solution:

Open /Applications/Gnuplot.app/Contents/Resources/bin/gnuplot in a text editor. Use the editor search-and-replace feature to replace “DYLD_LIBRARY_PATH” with “DYLD_FALLBACK_LIBRARY_PATH”. There are four instances that need to be replaced.

So create a backup of the gnuplot file, fire up VIM and replace all instances of “DYLD_LIBRARY_PATH” using the following command:

:%s/DYLD_LIBRARY_PATH/DYLD_FALLBACK_LIBRARY_PATH/g

After that, Octave will happily plot your sombrero:

octave-3.4.0:2> sombrero(50)

Hello world

My name is Simon Krenger, I am a Technical Account Manager (TAM) at Red Hat. I advise our customers in using Kubernetes, Containers, Linux and Open Source.

Elsewhere

  1. GitHub
  2. LinkedIn
  3. GitLab