I wish to run Emacs from the latest development version.

I've downloaded the latest Emacs development version from https://savannah.gnu.org/projects/emacs (with git clone -b master git://git.sv.gnu.org/emacs.git), ran autogen.sh as suggested here, then followed the instructions on the screen: after autogen.sh I executed ./autogen.sh git, then ./configure, and finally make (if I run make install instead, I get the same error message as below). All the steps except make seemed to finish successfully.

As for make, it started off well enough, but at some point it stopped with the following error message:

xml.c:23:10: fatal error: 'libxml/tree.h' file not found
#include <libxml/tree.h>
1 error generated.
make[1]: *** [xml.o] Error 1
make: *** [src] Error 2

My path includes /usr/local/Cellar/libxml2/2.9.4_3/include/libxml2, and this directory in turn contains libxml/tree.h.

How can I fix the problem?

I run macOS Sierra version 10.12.5 .

  • 1
    Install the libxml library (through homebrew)? – Dan Jul 17 '17 at 18:52
  • @Dan: libxml is not available via Homebrew. – Evan Aad Jul 17 '17 at 18:59
  • @Dan: However libxml2 is available through Homebrew. Will it do? – Evan Aad Jul 17 '17 at 19:08
  • FWIW, the sequence is make (to build the executable and everything else) and make install (to install the built executable and the rest). – wasamasa Jul 17 '17 at 19:24
  • 1
    This looks interesting: lists.gnu.org/archive/html/emacs-devel/2015-11/msg01940.html -- I'm not 100% certain it is applicable, but the bottom line of that particular thread is: "you are missing the command line tools for OSX. Try running xcode-select --install from the command line" – lawlist Jul 17 '17 at 21:50

The error message described in the question has previously been encountered by other fellow Emacs enthusiasts, and the recommended fix is to install OSX command line tools by running the following from the command line:

xcode-select --install

Here is the link to the Emacs development thread that described the above solution by Daniel Sutton:


| improve this answer | |
  • This solution does not work since macOS 10.14 – cjohansson Sep 29 '18 at 14:16
  • You can get the command line tools for 10.14 Mojave from the download site here: developer.apple.com/download/more Then you'll be able to install the headers as below in @carlbolduc's answer. – Emoses Oct 31 '18 at 17:56

The accepted answer does not work anymore since libxml2 will be installed inside the XCode directory. The solution is described here:


In short, Apple provides an installer that can put the librairies inside /usr/include. You can copy this installer to your desktop by doing this:

cp /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg ~/Desktop

Once copied, just launch the installer from your Desktop.

| improve this answer | |
  • 1
    This also works for the make error in openconnect – jim Mar 16 '19 at 12:31
  • this worked for me on new 10.14.4 – ikel Apr 26 '19 at 6:42

I successfully built emacs 26.3 from scratch on macOS 10.15.1 with libxml2 installed using brew without the nonsense in the first two answers. After installing libxml2 and running ./configure, I modified the CFLAGS and CPPFLAGS in emacs-26.3/src/Makefile to terminate with libxml2 instead of include:

CFLAGS = -I/usr/local/opt/libxml2/include/libxml2
CPPFLAGS = -I/usr/local/opt/libxml2/include/libxml2
| improve this answer | |
  • Another way to run this is: CFLAGS="-I/usr/local/opt/libxml2/include/libxml2" CPPFLAGS=-I/usr/local/opt/libxml2/include/libxml2 make install – rgiar Jan 22 at 3:04
  • 2
    @rgiar I'm old school, I like to keep a record of how it the binary was built so when I come back to recompile a year later I don't have to work this problem again. – Erik Jan 26 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.