9

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 .

13
  • 1
    Install the libxml library (through homebrew)? Commented Jul 17, 2017 at 18:52
  • @Dan: libxml is not available via Homebrew. Commented Jul 17, 2017 at 18:59
  • @Dan: However libxml2 is available through Homebrew. Will it do? Commented Jul 17, 2017 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). Commented Jul 17, 2017 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" Commented Jul 17, 2017 at 21:50

3 Answers 3

5

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:

http://lists.gnu.org/archive/html/emacs-devel/2015-11/msg01940.html

2
  • This solution does not work since macOS 10.14 Commented Sep 29, 2018 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. Commented Oct 31, 2018 at 17:56
27

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

https://silvae86.github.io/sysadmin/mac/osx/mojave/beta/libxml2/2018/07/05/fixing-missing-headers-for-homebrew-in-mac-osx-mojave/

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.

2
  • 1
    This also works for the make error in openconnect Commented Mar 16, 2019 at 12:31
  • this worked for me on new 10.14.4 Commented Apr 26, 2019 at 6:42
2

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
2
  • Another way to run this is: CFLAGS="-I/usr/local/opt/libxml2/include/libxml2" CPPFLAGS=-I/usr/local/opt/libxml2/include/libxml2 make install Commented Jan 22, 2020 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. Commented Jan 26, 2020 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.