【发布时间】:2016-11-18 17:13:53
【问题描述】:
我正在尝试在 r 中安装“XML”包,但出现错误。
请告诉我有什么问题。
操作系统:OS X 10.11.6
R 版本:3.3.2
执行“install.packages("XML") 时的错误信息如下。
* installing *source* package ‘XML’ ...
** package ‘XML’ successfully unpacked and MD5 sums checked
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for sed... /usr/bin/sed
checking for pkg-config... /usr/local/bin/pkg-config
checking for xml2-config... /usr/bin/xml2-config
USE_XML2 = yes
SED_EXTENDED_ARG: -E
Minor 9, Patch 2 for 2.9.2
Located parser file -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/libxml2/parser.h
Checking for 1.8: -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/libxml2
Using libxml2.*
checking for gzopen in -lz... yes
checking for xmlParseFile in -lxml2... no
checking for xmlParseFile in -lxml... no
configure: error: "libxml not found"
ERROR: configuration failed for package ‘XML’
我设置 LIBXML_INCDIR=/usr/local/Cellar/libxml2/2.9.4,然后再试一次。
然后发生另一个错误。
* installing *source* package ‘XML’ ...
** package ‘XML’ successfully unpacked and MD5 sums checked
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for sed... /usr/bin/sed
checking for pkg-config... /usr/local/bin/pkg-config
Checking directory of LIBXML_INCDIR
You specified LIBXML_INCDIR, but we couldn't find parser.h
Please specify it correctly and re-run the INSTALL'ation.
ERROR: configuration failed for package ‘XML’
还尝试使用 LIBXML_INCDIR=/usr/local/Cellar/libxml2/2.9.4/include
结果和上面一样。
问候
【问题讨论】:
-
看来问题不在于
LIBXML_INCDIR,而是找不到共享库文件。在第一次尝试中找到parser.h,当您未指定时:Located parser file -I/Applications/Xcode.app/[...]。 -
感谢您的评论。我猜LIBXML_INCDIR在第一次尝试时不是问题,但是我对解决方案没有任何想法,所以我尝试了一下,只是因为LIBXML_INCDIR据说与某些网页上的libxml有关。请原谅我缺乏解释。
-
尝试从终端运行
brew link libxml2,然后重新安装R包。 -
非常感谢。 “brew link libxml2 --force”有效。
-
@Ken 我遇到了同样的问题,但
brew link libxml2 --force不适合我。你在哪里指定LIBXML_INCDIR=/usr/local/Cellar/libxml2/2.9.4/include?感谢您在此处提供的任何帮助。