Skip to content

configure fails to find libxml (macOS toolchain issue?) #296

Closed
@kevinushey

Description

@kevinushey

When I try to install xml2 from sources, I'm seeing:

$ R CMD INSTALL --preclean .
* installing to library ‘/Users/kevinushey/Library/R/3.6/library’
* installing *source* package ‘xml2’ ...
** using staged installation
Found pkg-config cflags and libs!
Using PKG_CFLAGS=-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
Using PKG_LIBS=-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lxml2 -lz -lpthread -licucore -lm
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libxml-2.0 was not found. Try installing:
 * deb: libxml2-dev (Debian, Ubuntu, etc)
 * rpm: libxml2-devel (Fedora, CentOS, RHEL)
 * csw: libxml2_dev (Solaris)
If libxml-2.0 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libxml-2.0.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
ERROR: configuration failed for package ‘xml2’
* removing ‘/Users/kevinushey/Library/R/3.6/library/xml2’
* restoring previous ‘/Users/kevinushey/Library/R/3.6/library/xml2’

Note: the configure output above indicates that the flags are coming from pkg-config, but they're really coming from xml2-config in this case.

If I understand correctly, it seems like xml2-config is providing the wrong flags:

$ xml2-config --cflags && xml2-config --libs
-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
-L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib -lxml2 -lz -lpthread -licucore -lm

as the requisite xml2 includes aren't actually available in that directory.

FWIW, pkg-config (installed from Homebrew) seems to get it right:

kevinushey@Kevins-MBP:~/r/pkg/xml2 [master]
$ pkg-config libxml-2.0 --cflags && pkg-config libxml-2.0 --libs
-I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/libxml2
-lxml2

Note: #232 (comment) is likely related.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions