Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't build GNU Emacs or Remacs on macOS 10.14 Mojave - fatal error: 'libxml/tree.h' file not found #886

Closed
cjohansson opened this issue Oct 1, 2018 · 15 comments

Comments

Projects
None yet
6 participants
@cjohansson
Copy link
Contributor

commented Oct 1, 2018

Might be off-topic but I get this error on macOS 10.14 Mojave, after running make:

xml.c:23:10: fatal error: 'libxml/tree.h' file not found

Both xcode-select --install and brew install libxml2 is installed. I get the same error on GNU Emacs as well. Do you get this error or do you know about a solution to it?

I didn't get this error before updating macOS to Mojave.

@cjohansson cjohansson changed the title Can't build GNU Emacs or Remacs on macOS "Mojave xml.c:23:10: fatal error: 'libxml/tree.h' file not found" Can't build GNU Emacs or Remacs on macOS Mojave - fatal error: 'libxml/tree.h' file not found Oct 1, 2018

@cjohansson cjohansson changed the title Can't build GNU Emacs or Remacs on macOS Mojave - fatal error: 'libxml/tree.h' file not found Can't build GNU Emacs or Remacs on macOS 10.14 Mojave - fatal error: 'libxml/tree.h' file not found Oct 1, 2018

@shaleh

This comment has been minimized.

Copy link
Collaborator

commented Oct 1, 2018

I have not upgraded yet.

@socketwiz

This comment has been minimized.

Copy link

commented Oct 3, 2018

I also upgraded to Mojave and I ran into this problem. I solved it by using homebrew to install libxml2:

$ brew install libxml2

If you have already installed libxml2 then you can see what environment variables it wants you to set by doing brew info libxml2. Here is what it said on my machine.

$ export LDFLAGS="-L/usr/local/opt/libxml2/lib"
$ export CPPFLAGS="-I/usr/local/opt/libxml2/include"
$ export PKG_CONFIG_PATH="/usr/local/opt/libxml2/lib/pkgconfig"

Once you have your environment updated with libxml2 then you need to re-run configure so it can pickup libxml2 from the environment you've setup.

$ ./configure --enable-rust-debug

Now you should be able to re-run make. It built to completion for me when I did this. It took just over 2 hours on my machine.

$ make
@db48x

This comment has been minimized.

Copy link
Collaborator

commented Oct 3, 2018

$ export PKG_CONFIG_PATH="/usr/local/opt/libxml2/lib/pkgconfig"

This is all you need. The configure script will run pkg-config to find out what to add to LDFLAGS and CPPFLAGS.

@cjohansson

This comment has been minimized.

Copy link
Contributor Author

commented Oct 3, 2018

Yes it's working @db48x , I have this in my ~/.bash_profile now:

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/opt/libxml2/lib/pkgconfig:/opt/X11/li
    b/pkgconfig:$PKG_CONFIG_PATH

Running brew link libxml2 gives that as an advice as well but I only tried the first two advices (LDFLAGS and CPPFLAGS) which didn't work.

I'm a bit curious why the built-in libxml2 from Xcode located at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libxml2/ doesn't work anymore. xcode-select --install was the only requirement before Mojave but now it's not enough anymore..

@shaleh

This comment has been minimized.

Copy link
Collaborator

commented Oct 3, 2018

@cjohansson maybe the Xcode version is not in PKG_CONFIG_PATH?

@cjohansson

This comment has been minimized.

Copy link
Contributor Author

commented Oct 11, 2018

The Xcode version does not seem to have a pkgconfig directory and setting the environment variables LDFLAGS or CPPFLAGS seems to have no effect. So brew install libxml2 and export PKG_CONFIG_PATH="/usr/local/opt/libxml2/lib/pkgconfig" seems like the only option at the moment. It's the same when building GNU Emacs

@brotzeit

This comment has been minimized.

Copy link
Collaborator

commented Nov 7, 2018

Can we close this issue ?

@cjohansson

This comment has been minimized.

Copy link
Contributor Author

commented Nov 7, 2018

Yes sure but we should probably update the build instructions for macOS with the extra brew install libxml2; export PKG_CONFIG_PATH="/usr/local/opt/libxml2/lib/pkgconfig"

@cjohansson cjohansson closed this Nov 7, 2018

@shaleh

This comment has been minimized.

Copy link
Collaborator

commented Nov 7, 2018

@brotzeit I re-opened this so you can close it after updating the docs.

@Leimy

This comment has been minimized.

Copy link

commented Dec 6, 2018

Should be fine to use the Xcode headers... you just need to copy them out, and Apple provided a package for this. They hid it well.

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

Then launch it from your desktop. After, I'm able to build Emacs at least. Haven't tried Remacs yet.

@shaleh

This comment has been minimized.

Copy link
Collaborator

commented Dec 6, 2018

@Leimy if this work, can you submit a PR to update the our docs?

@Leimy

This comment has been minimized.

Copy link

commented Dec 6, 2018

Well it works for Emacs. Have not tried REmacs yet. I might get around to that eventually but I feel like someone more involved with the project may beat me to it.

@shaleh

This comment has been minimized.

Copy link
Collaborator

commented Dec 6, 2018

Many of us hacking on remacs have not upgraded yet. I know I haven't.

@cjohansson

This comment has been minimized.

Copy link
Contributor Author

commented Dec 7, 2018

I tested this and it works, I was able to build using this command

export PKG_CONFIG_PATH="/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg" && cd ~/Documents/remacs/ && git pull origin master && rustup update `cat rust-toolchain` && ./autogen.sh && ./configure && make clean && make && make install;

so there is no need for installing libxm2 via brew, I'll update the docs later

@cjohansson

This comment has been minimized.

Copy link
Contributor Author

commented Dec 9, 2018

It seems it was a false positive, but doing open Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg and installing it before building remacs works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.