4

I have environment below, CentOS release 6.4, R version 3.2.2.

I wanted to install the "rgl" package for R. At the beginning, I used install.packages("rgl"), it throws error below:

 Installing package into ‘/usr/lib64/R/library’
(as ‘lib’ is unspecified)
trying URL 'http://mirror.bjtu.edu.cn/cran/src/contrib/rgl_0.95.1367.tar.gz'
Content type 'application/octet-stream' length 2033202 bytes (1.9 MB)
==================================================
downloaded 1.9 MB

* installing *source* package ‘rgl’ ...
** package ‘rgl’ successfully unpacked and MD5 sums checked
checking for gcc... gcc -m64 -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -m64 -std=gnu99 accepts -g... yes
checking for gcc -m64 -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -m64 -std=gnu99 -E
checking for gcc... (cached) gcc -m64 -std=gnu99
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc -m64 -std=gnu99 accepts -g... (cached) yes
checking for gcc -m64 -std=gnu99 option to accept ISO C89... (cached) none needed
checking whether __attribute__((visibility())) is supported... yes
checking whether gcc -m64 -std=gnu99 accepts -fvisibility... yes
checking whether  accepts -fvisibility... no
checking for libpng-config... no
checking libpng... 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 png.h usability... no
checking png.h presence... no
checking for png.h... no
checking for png_read_update_info in -lpng... no
configure: libpng header and lib found
configure: using libpng dynamic linkage
checking for X... no
configure: error: X11 not found but required, configure aborted.
ERROR: configuration failed for package ‘rgl’
* removing ‘/usr/lib64/R/library/rgl’

The downloaded source packages are in
    ‘/tmp/Rtmp6mou8m/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("rgl") :
  installation of package ‘rgl’ had non-zero exit status

Then I tried to install the "rgl" package using R CMD.I downloaded the "rgl_0.95.1367.tar.gz" from http://cran.at.r-project.org/web/packages/rgl/index.html. I installed it by R CMD INSTALL command:

[root@srv005 RFile]# R CMD INSTALL -l rgl_0.95.1367.tar.gz 
Error: ERROR: no packages specified
[root@srv005 RFile]# R CMD INSTALL rgl_0.95.1367.tar.gz 
* installing to library ?.usr/lib64/R/library?
* installing *source* package ?.gl?....
** package ?.gl?.successfully unpacked and MD5 sums checked
checking for gcc... gcc -m64 -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -m64 -std=gnu99 accepts -g... yes
checking for gcc -m64 -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -m64 -std=gnu99 -E
checking for gcc... (cached) gcc -m64 -std=gnu99
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc -m64 -std=gnu99 accepts -g... (cached) yes
checking for gcc -m64 -std=gnu99 option to accept ISO C89... (cached) none needed
checking whether __attribute__((visibility())) is supported... yes
checking whether gcc -m64 -std=gnu99 accepts -fvisibility... yes
checking whether  accepts -fvisibility... no
checking for libpng-config... no
checking libpng... 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 png.h usability... no
checking png.h presence... no
checking for png.h... no
checking for png_read_update_info in -lpng... no
configure: libpng header and lib found
configure: using libpng dynamic linkage
checking for X... no
configure: error: X11 not found but required, configure aborted.
ERROR: configuration failed for package ?.gl?
* removing ?.usr/lib64/R/library/rgl?

It doesn't work neither.

Is there anyone knows how to install this "rgl" package in CentOS? Or the package can't be installed in the CentOS at all? Thanks.

Community
  • 1
  • 1
Gavin
  • 589
  • 1
  • 6
  • 20
  • 4
    You need to install X11 libraries (and possibly the development versions of the libraries) , but I don't know how on that OS: does this help https://www.centos.org/forums/viewtopic.php?t=5933 ? – Ben Bolker Nov 04 '15 at 02:38
  • 3
    You need also png library. –  Nov 04 '15 at 02:55
  • Why do we need png library? It seems no change after adding it. @Pascal – Gavin Nov 04 '15 at 03:48
  • It is written it is not found. Please read error message. Anyway, did you also install OpenGL and GLU Library, as written here: https://cran.r-project.org/web/packages/rgl/index.html –  Nov 04 '15 at 03:50
  • Oh, got it. Thanks @Pascal – Gavin Nov 04 '15 at 03:52
  • Yeah, you are correct. Thanks. @BenBolker – Gavin Nov 04 '15 at 03:54

2 Answers2

2

On RHEL you have to install libX11-devel, AFAIR

sudo yum install libX11-devel

I guess it is the same on CentOS.

Ott Toomet
  • 1,894
  • 15
  • 25
  • You also need png libs. –  Nov 04 '15 at 03:10
  • Thanks, it works. I installed the libX11-devel, and then I used `install.packages("rgl")` successfully. But when I use it, there is a warning msg, `library("rgl") Warning messages: 1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display 2: In fun(libname, pkgname) : Error in 'rgl_init'`. I searched online, there is a solution, add `options(rgl.useNULL=TRUE)`. I added it, the warning msg gone, but then it seems I can't use 3D plot. Do you know anyway that can let me use 3D plot? Thanks. – Gavin Nov 04 '15 at 03:46
  • Can you use 3d acceleration outside of rgl? For instance does `glxgears` work? – Ott Toomet Nov 04 '15 at 04:25
  • When I try to install the `glxgears`, it gives me : `Warning message: package ?.lxgears?.is not available (for R version 3.2.2) `. – Gavin Nov 04 '15 at 05:54
  • glxgears seems to be a part of `glx-utils`. Do you have it installed? – Ott Toomet Nov 04 '15 at 16:27
2

I also had to install openGL and GLU libraries.

sudo yum install mesa-libGL mesa-libGL-devel mesa-libGLU mesa-libGLU-devel
sudo yum groupinstall X11
Stephen Turner
  • 2,574
  • 8
  • 31
  • 44