簡體   English   中英

如何指定在安裝R軟件包時使用哪個R庫?

[英]how to specify which R lib to use when installing a R package?

我試圖使用一個名為“ XML”的R包 ,但是在安裝后無法使用它:

# in R environment
> library("XML")
> XML::parseURI("")
Error in XML::parseURI("") : cannot parse URI 

問題原來是R無法在我的目錄中找到安裝的“ libxml2”的當前版本:

 echo $LD_LIBRARY_PATH /somewhere/Jun/Programme/libxml2-devel-2.9.1-2.1/usr/lib/:

檢索有關鏈接到的libxml2庫“ XML”版本的信息

> path = unclass(getLoadedDLLs()[["XML"]])$path
> path
[1] "/misc/home/Jun/Programme/R-3.3.1/lib64/R/library/XML/libs/XML.so"
> system2("ldd",args=path)
                linux-vdso.so.1 =>  (0x00007fff2a9e8000)
                libxml2.so.2 => /usr/lib64/libxml2.so.2 (0x00002aefc088a000)  # XML is using a common "libxml2.so.2" not the one I installed. 
                libz.so.1 => //home/Jun/Programme/zlib-1.2.11/lib/libz.so.1 (0x00002aefc0bc8000)
                libm.so.6 => /lib64/libm.so.6 (0x00002aefc0de5000)
                libdl.so.2 => /lib64/libdl.so.2 (0x00002aefc1068000)
                ...

有什么建議嗎?

為了使“ XML”鏈接到安裝在我的目錄中的libxml2,我做了以下努力:

  1. 為libxml2設置PATH:

    回聲$ LD_LIBRARY_PATH

    /somewhere/Jun/Programme/pcre-8.40/lib/:/somewhere/Jun/Programme/xz-5.2.3/lib/:/somewhere/Jun/Programme/zlib-1.2.11/include/:/somewhere/Jun /Programme/zlib-1.2.11/lib/:/somewhere/Jun/Programme/bzip2-1.0.6/lib/:/somewhere/Jun/Programme/bzip2-1.0.6/include/:/somewhere/Jun/Programme /gcc-6.1.0/lib/:/somewhere/Jun/Programme/gcc-6.1.0/lib64/:/somewhere/Jun/Programme/libxml2-devel-2.9.1-2.1/usr/lib/:/somewhere /Jun/Programme/curl-7.52.1/lib/:/somewhere/Jun/Programme/libtool_CentOS6_64/usr/lib64/:/home/appl/openmpi-1.3.1/lib:/opt22/lsf83_exp/8.3/linux2。 6 glibc2.3-x86_64的/ lib目錄中:/ opt / UPS / lib目錄

  2. 使用“ --enable”參數用指定lib的配置重新編譯R

    ./configure --prefix = $ HOME / Programme / R-3.3.1 --enable-R-shlib LDFLAGS =“-L / $ HOME / Programme / zlib-1.2.11 / lib -L ​​/ $ HOME / Programme / bzip2-1.0.6 / lib -L ​​/ $ HOME / Programme / xz-5.2.3 / lib -L ​​/ $ HOME / Programme / pcre-8.40 / lib -L ​​/ $ HOME / Programme / curl-7.52.1 / lib “ CPPFLAGS =“-I / $ HOME / Programme / zlib-1.2.11 / include -I / $ HOME / Programme / bzip2-1.0.6 / include -I / $ HOME / Programme / xz-5.2.3 / include- I / $ HOME / Programme / pcre-8.40 / include -I / $ HOME / Programme / curl-7.52.1 / include“

  3. 使用配置參數安裝“ XML”:

    biocLite(“ XML”,configure.args ='-with-xml- config =“ / somewhere / Jun / Programme / libxml2-devel-2.9.1-2.1 / usr / bin / xml2-config”')BioC_mirror: http ://bioconductor.org使用Bioconductor 3.4(BiocInstaller 1.24.0),R 3.3.1(2016-06-21)。 安裝包“ XML”並嘗試使用網址“ http://cran.rstudio.com/src/contrib/XML_3.98-1.5.tar.gz

    內容類型“應用程序/ x-gzip”長度1599213字節(1.5 MB)

    下載1.5 MB ...

但它們似乎都不起作用:

* 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... /bin/sed
checking for pkg-config... /usr/bin/pkg-config
User defined xml-config: /somewhere/Jun/Programme/libxml2-devel-2.9.1-2.1/usr/bin/xml2-config, XML Version: 2, XML2: yes
USE_XML2 = yes
SED_EXTENDED_ARG: -r
Minor 9, Patch 1 for 2.9.1
Located parser file -I/usr/include/libxml2/parser.h
checking for gzopen in -lz... yes
checking for xmlParseFile in -lxml2... yes
checking for xmlHashSize in -lxml2... yes
Using built-in xmlHashSize
Checking DTD parsing (presence of externalSubset)...
checking for xmlHashSize in -lxml2... yes
Found xmlHashSize
checking for xmlOutputBufferCreateBuffer in -lxml2... yes
have xmlOutputBufferCreateBuffer()
checking for xmlDocDumpFormatMemoryEnc in -lxml2... yes
checking libxml/xmlversion.h usability... yes
checking libxml/xmlversion.h presence... yes
checking for libxml/xmlversion.h... yes
Expat:  FALSE
Checking for return type of xmlHashScan element routine.
No return value for xmlHashScan
xmlNs has a context field
Checking for cetype_t enumeration
Using recent version of R with cetype_t enumeration type for encoding
checking for xmlsec1-config... /usr/bin/xmlsec1-config
nodegc default 
xml-debug default 
No XML_WITH_ZLIB enumeration value.
Version has xmlHasFeature()

****************************************
Configuration information:

Libxml settings

libxml include directory: -I/usr/include/libxml2
libxml library directory: -lxml2 -lz -lm -ldl -lz  -lxml2
libxml 2:                 -DLIBXML2=1

我想我已經找到了解決方案。 與其使用rpm安裝“ libxml2”,(我很抱歉在我的帖子中沒有提到它;我沒有意識到這可能是造成麻煩的原因),我應該從源代碼編譯“ libxml2”。

對於有類似問題的人:

http://www.linuxfromscratch.org/blfs/view/svn/general/libxml2.html下載libxml2的當前版本,

請按照上面鏈接的說明進行操作。

安裝兩點:

1。

./configure --prefix=$HOME/Programme --disable-static --with-history --with-zlib=/somewhere/Jun/Programme/zlib-1.2.11 && make

您必須指定zlib(--with); 這也意味着您必須安裝zlib。 我必須添加“ --with”以使configure工作。

  1. 說明說明您必須以root用戶身份調用“ make install”,但沒有,您不必這樣做。

  2. 為您安裝的“ libxml2”設置PATH

  3. 重新安裝您的R包“ XML”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM