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

Build failing on MacOS X #88

Closed
ballsteve opened this issue Jun 23, 2021 · 4 comments
Closed

Build failing on MacOS X #88

ballsteve opened this issue Jun 23, 2021 · 4 comments

Comments

@ballsteve
Copy link

When I try using the libxml crate on a Mac OS X laptop, I get the following build error:

thread 'main' panicked at 'Could not find libxml2.', /Users/balls/.cargo/registry/src/github.com-1ecc6299db9ec823/libxml-0.3.0/build.rs:25:5

This appears to be similar to other issues (#81, #72), but they were on Windows so I don't think the answer/resolution will be the same.

Is the crate looking for an existing installation of libxml2? If so then how can I point the build to it?

@ballsteve
Copy link
Author

This issue is now resolved. The steps taken were as follows:

I downloaded, built and installed the libxml2-2.9.12 tarball, using --prefix=/usr/local

Set environment variable LIBXML2=/usr/local/lib/pkgconfig/libxml-2.0.pc; export LIBXML2

cargo build was then successful.

I would suggest adding these steps to the README.

@dginev
Copy link
Member

dginev commented Jun 23, 2021

Thanks for troubleshooting that installation @ballsteve ! I am surprised, I would've expected Mac OS to be successful via the pkg-config route. I am not a Mac user myself, but pkg-config seems widely available on the various package managers.

The resolution path you've taken was meant for embedded devices that can't add extra dependencies, so while I'm happy you got things working, it's also too manual to be satisfied...

@ballsteve
Copy link
Author

Further to the above resolution, I also had to create a symbolic link for /usr/local/lib/libxml-2.0.dylib to libxml2.2.dylib. So that's even more manual intervention required!

@hurlenko
Copy link

hurlenko commented Aug 2, 2021

Thanks to @ballsteve, here are the steps it took me to compile this crate on macOS:

  1. brew install libxml2 # v 2.9.12 in my case
  2. ln -s /usr/local/Cellar/libxml2/2.9.12/lib/libxml2.2.dylib /usr/local/lib/libxml-2.0.dylib
  3. export LIBXML2=/usr/local/Cellar/libxml2/2.9.12/lib/pkgconfig/libxml-2.0.pc
  4. cargo build

Adding these steps, along with the windows compilation instruction to the README would be really nice 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants