Incompatible library version: requires version 19.0.0 or later, but .dylib provides version 18.0.0

I was trying to compile simple test application with FreeType2 on macOS just by a command line. Application compiled without problem.

The application was not able to start and displayed following error:

There is one handy tool on macOS which helps in cases like this one: otool.

The problem was caused by two versions of libfreetype on the macOS. One library was stored in /usr/local/lib and the other was stored in my project directory.

How to fix the issue? There are two options:

  • Remove unwanted library which is causing ambiguity
  • Set proper paths to DYLD_LIBRARY_PATH before starting the application