安装Rgraphviz遇到的怪异问题(已解决)

在安装了graphviz之后,在R当中安装Rgraphviz。命令:

[ouj@qiuworld ~]$ sudo R CMD INSTALL Rgraphviz_1.30.1.tar.gz 
[sudo] password for ouj: 
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 grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
checking for whether compiler has bool... yes
configure: No --with-graphviz option was specified. Trying to find Graphviz using other methods.
checking for pkg-config... /usr/bin/pkg-config
Package libgvc was not found in the pkg-config search path.
Perhaps you should add the directory containing `libgvc.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libgvc' found
configure: pkg-config was not able to find the Graphviz library libgvc. This either indicates that Graphviz is old or that something is wrong. Verify Graphviz is installed and that PKG_CONFIG_PATH is correct.
checking for dotneato-config... no
configure: dotneato-config not found in PATH.
configure: Using default directory /usr/local, consider specifiying --with-graphviz
configure: Found Graphviz version '2.28.0'.
configure: Graphviz major version is '2' and minor version is '28'.
configure: Using the following compilation and linking flags for Rgraphviz
configure:    PKG_CPPFLAGS=-I/usr/local/include/graphviz
configure:    PKG_LIBS=-L/usr/local/lib/graphviz -L/usr/local/lib -lgvc
configure:    GVIZ_DEFS= -DHAVE_STDBOOL_H=1 -DHAVE_BOOL=1 -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=28 
configure: Setting Graphviz Build version to '2.28.0'.
configure: creating ./config.status
config.status: creating R/graphviz_build_version.R
config.status: creating src/Makevars
** libs
gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/include/graphviz  -DHAVE_STDBOOL_H=1 -DHAVE_BOOL=1 -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=28  -I/usr/local/include    -fpic  -g -O2 -c LL_funcs.c -o LL_funcs.o
gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/include/graphviz  -DHAVE_STDBOOL_H=1 -DHAVE_BOOL=1 -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=28  -I/usr/local/include    -fpic  -g -O2 -c Rgraphviz.c -o Rgraphviz.o
gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/include/graphviz  -DHAVE_STDBOOL_H=1 -DHAVE_BOOL=1 -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=28  -I/usr/local/include    -fpic  -g -O2 -c RgraphvizInit.c -o RgraphvizInit.o
gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/include/graphviz  -DHAVE_STDBOOL_H=1 -DHAVE_BOOL=1 -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=28  -I/usr/local/include    -fpic  -g -O2 -c agopen.c -o agopen.o
gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/include/graphviz  -DHAVE_STDBOOL_H=1 -DHAVE_BOOL=1 -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=28  -I/usr/local/include    -fpic  -g -O2 -c agread.c -o agread.o
gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/include/graphviz  -DHAVE_STDBOOL_H=1 -DHAVE_BOOL=1 -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=28  -I/usr/local/include    -fpic  -g -O2 -c agwrite.c -o agwrite.o
gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/include/graphviz  -DHAVE_STDBOOL_H=1 -DHAVE_BOOL=1 -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=28  -I/usr/local/include    -fpic  -g -O2 -c bezier.c -o bezier.o
gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/include/graphviz  -DHAVE_STDBOOL_H=1 -DHAVE_BOOL=1 -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=28  -I/usr/local/include    -fpic  -g -O2 -c buildEdgeList.c -o buildEdgeList.o
gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/include/graphviz  -DHAVE_STDBOOL_H=1 -DHAVE_BOOL=1 -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=28  -I/usr/local/include    -fpic  -g -O2 -c buildNodeList.c -o buildNodeList.o
gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/include/graphviz  -DHAVE_STDBOOL_H=1 -DHAVE_BOOL=1 -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=28  -I/usr/local/include    -fpic  -g -O2 -c doLayout.c -o doLayout.o
gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/include/graphviz  -DHAVE_STDBOOL_H=1 -DHAVE_BOOL=1 -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=28  -I/usr/local/include    -fpic  -g -O2 -c graphvizVersion.c -o graphvizVersion.o
gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/include/graphviz  -DHAVE_STDBOOL_H=1 -DHAVE_BOOL=1 -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=28  -I/usr/local/include    -fpic  -g -O2 -c init.c -o init.o
gcc -std=gnu99 -shared -L/usr/local/lib64 -o Rgraphviz.so LL_funcs.o Rgraphviz.o RgraphvizInit.o agopen.o agread.o agwrite.o bezier.o buildEdgeList.o buildNodeList.o doLayout.o graphvizVersion.o init.o -L/usr/local/lib/graphviz -L/usr/local/lib -lgvc
installing to /usr/local/lib64/R/library/Rgraphviz/libs
** R
** inst
** preparing package for lazy loading
Creating a new generic function for "head" in "Rgraphviz"
Creating a new generic function for "tail" in "Rgraphviz"
Creating a new generic function for "lines" in "Rgraphviz"
Creating a new generic function for "plot" in "Rgraphviz"
** help
*** installing help indices
** building package indices ...
** testing if installed package can be loaded
Error : .onLoad failed in loadNamespace() for 'Rgraphviz', details:
  call: value[[3L]](cond)
  error: unable to load shared object '/usr/local/lib64/R/library/Rgraphviz/libs/Rgraphviz.so':
  libgvc.so.6: cannot open shared object file: No such file or directory
 
  Check that (1) graphviz is installed on your system; (2) the
  installed version of graphviz matches '2.28.0'; this is the version
  used to build this Rgraphviz package; (3) graphviz is accessible to
  R, e.g., the path to the graphviz 'bin' directory is in the system
  'PATH' variable.  See additional instructions in the 'README' file of
  the Rgraphviz 'source' distribution, available at
 
  http://bioconductor.org/packages/release/bioc/html/Rgraphviz.html
 
  Ask further questions on the Bioconductor mailing list
 
  http://bioconductor.org/docs/mailList.html
 
 
Error: loading failed
Execution halted
ERROR: loading failed

不知道如何解决。在网上搜索了两天之后,并在邮件组里分问,分析认为是动态链接库的问题。解压原代码安装包,测试:

[ouj@qiuworld ~]$ R CMD ldd /usr/local/lib/libgvc.so.6
	linux-vdso.so.1 =>  (0x00007fff173fc000)
	libxdot.so.4 => /usr/local/lib/libxdot.so.4 (0x00002b5c100e0000)
	libgraph.so.5 => /usr/local/lib/libgraph.so.5 (0x00002b5c102e4000)
	libcdt.so.5 => /usr/local/lib/libcdt.so.5 (0x00002b5c104f0000)
	libpathplan.so.4 => /usr/local/lib/libpathplan.so.4 (0x00002b5c106f5000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00002b5c10914000)
	libexpat.so.0 => /lib64/libexpat.so.0 (0x00002b5c10b18000)
	libz.so.1 => /usr/lib64/libz.so.1 (0x00002b5c10d3a000)
	libm.so.6 => /lib64/libm.so.6 (0x00002b5c10f4f000)
	libc.so.6 => /lib64/libc.so.6 (0x00002b5c111d2000)
	/lib64/ld-linux-x86-64.so.2 (0x000000349cc00000)
[ouj@qiuworld ~]$ sudo R CMD ldd Rgraphviz/src/Rgraphviz.so
[sudo] password for ouj: 
	linux-vdso.so.1 =>  (0x00007fff58b40000)
	libgvc.so.6 => not found
	libc.so.6 => /lib64/libc.so.6 (0x00002aacd51ae000)
	/lib64/ld-linux-x86-64.so.2 (0x000000349cc00000)

果然。可是没有办法使用export 为sudo 输出共亨链接库,只好先使用

[ouj@qiuworld ~]$ sudo LD_LIBRARY_PATH=/usr/lib:/usr/local/lib R CMD INSTALL Rgraphviz_1.30.1.tar.gz
...

先安装上。接下来的问题是如何将LD_LIBRARY_PATH=LD_LIBRARY_PATH:/usr/local/lib写给每个用户,并在每次登录的时候都可以正常使用。否则在使用Rgraphviz包时,都需要LD_LIBRARY_PATH=/usr/lib:/usr/local/lib R来启动R。

[ouj@qiuworld ~]$ sudo vi /etc/ld.so.conf.d/Rgraphviz.conf

在文件中写入一行:

/usr/local/lib

然后保存退出。

[ouj@qiuworld ~]$ sudo /sbin/ldconfig

而后退出ssh,再次登录

[ouj@qiuworld ~]$ R
 
R version 2.13.0 (2011-04-13)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-unknown-linux-gnu (64-bit)
 
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
 
  Natural language support but running in an English locale
 
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
 
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
 
> library(Rgraphviz)
Loading required package: graph
Loading required package: grid

一切OK。

Leave a Reply

  

  

  

%d 博主赞过: