If, like me, you tried installing imagemagick or other software using Homebrew, you might have ran into this error:
This took me one day to fix, because usually everyone tells you to run xcode-select --install. This does not fix the problem.
Why this happens
Mac OS X 10.14 has stopped placing the include libraries in their usual location, /usr/include, keeping them only inside the XCode directory.
To confirm that this is the problem, simply run ls /usr/include. If the result comes out empty, its really this problem.
By running find / | grep libxml/parser.h I can find the libxml library in several places:
What you should not do
Some would say that you should just link the path where the libraries are to /usr/include. This is not right, as it overrides the default behaviour expected by Mac OS and requires you to disable SIP (System Integrity Protection). Sometimes it is needed, but this is not one of those times. Leave csrutil alone.
You CANNOT modify /usr/include, even with the root user. It is locked by SIP, so if you try you will get a Operation not permitted error.
What worked for me
Apple ships a “legacy installer” for you to be able to install the headers in the “old location”. Run this:
Then, the installer will be placed at your Destop. Simple double-click and it will install the headers in /usr/include.
or, if you want a pure command line alternative:
The /usr/include directory now includes all the libraries required by brew to link during package compilation:
Now imagemagick and other kegs will install successfully.