9

It seems that I have troubles isntalling the rgl package on Ubuntu. When running

install.packages("rgl")

I got the following error

checking for gcc... gcc -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 -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for gcc... (cached) gcc -std=gnu99
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc -std=gnu99 accepts -g... (cached) yes
checking for gcc -std=gnu99 option to accept ISO C89... (cached) none needed
checking whether __attribute__((visibility())) is supported... yes
checking whether gcc -std=gnu99 accepts -fvisibility... yes
checking whether  accepts -fvisibility... no
checking for libpng-config... yes
configure: using libpng-config
configure: using libpng dynamic linkage
checking for X... libraries , headers 
checking GL/gl.h usability... yes
checking GL/gl.h presence... yes
checking for GL/gl.h... yes
checking GL/glu.h usability... no
checking GL/glu.h presence... no
checking for GL/glu.h... no
Warning in install.packages :
  installation of package \u2018rgl\u2019 had non-zero exit status

It looks like the error appears in the alst three lines. My session info is

> sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] parallel  stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] doMC_1.3.3                    doParallel_1.0.8             
 [3] bit64_0.9-4                   bit_1.1-12                   
 [5] Defaults_1.1-1                quantstrat_0.9.1669          
 [7] blotter_0.9.1666              Rcpp_0.11.5                  
 [9] iterators_1.0.7               foreach_1.4.2                
[11] base64enc_0.1-2               FinancialInstrument_1.2.0    
[13] quantmod_0.4-4                PerformanceAnalytics_1.4.3541
[15] TTR_0.22-0                    data.table_1.9.4             
[17] xts_0.9-7                     zoo_1.7-12                   

loaded via a namespace (and not attached):
[1] chron_2.3-45     codetools_0.2-10 compiler_3.1.2   grid_3.1.2      
[5] lattice_0.20-30  plyr_1.8.1       reshape2_1.4.1   stringr_0.6.2   
[9] tools_3.1.2  

Does anybody know where is the catch?

Steef Gregor
  • 544
  • 1
  • 7
  • 21

4 Answers4

13

You actually need the following packages:

  libcgal-dev, libglu1-mesa-dev, libglu1-mesa-dev

You can install them on a machine with apt-get as follows:

sudo apt-get install libcgal-dev libglu1-mesa-dev libglu1-mesa-dev

That should solve the dependency problems


To install X11 header files:

sudo apt-get install libx11-dev
Kartik
  • 8,347
  • 39
  • 73
  • 1
    Aren't the last two packages of the three the same? – Code42 Jun 02 '19 at 14:57
  • @Code42 I believe one of these should be `libgl-mesa-dev`. I can't suggest an edit now as there are too many edits in the queue, unfortunately.. – bert Jun 27 '23 at 07:15
10

You need OpenGL libraries installed. The easiest thing to do will be to add Michael Rutter's PPA to your repository list and installing r-cran-rgl:

sudo add-apt-repository ppa:marutter/rrutter
sudo apt-get update
sudo apt-get install r-cran-rgl

If you need to run without X11, I believe that the answer to this question will help (you may need to sudo apt-get install xvfb first ...)

Community
  • 1
  • 1
Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
  • 1
    Tried the code you provided. It worked and downloaded all the stuff. But then, when typing `require("rgl")` I got this error: `Loading required package: rgl Warning messages: 1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display 2: In fun(libname, pkgname) : error in rgl_init` – Steef Gregor Apr 06 '15 at 21:05
  • sorry, don't know. Are you running this on a headless/remote server? What happens if you do `x11()` from within R? – Ben Bolker Apr 06 '15 at 21:38
  • I run it on dedicated server. Typing `x11()` results in `Error in .External2(C_X11, d$display, d$width, d$height, d$pointsize, : unable to start device X11cairo In addition: Warning message: In x11() : unable to open connection to X11 display ''` – Steef Gregor Apr 06 '15 at 21:42
10

Here we are on Ubuntu 18.04 and have similar problems installing rgl.

So we add all this dependencies (some taken from previous answers):

sudo apt install libftgl2 libcgal-dev libglu1-mesa-dev libglu1-mesa-dev libx11-dev libfreetype6-dev

and after lot of trying, we got it working !

We also published this solution here: https://r-forge.r-project.org/tracker/?group_id=234&atid=946&func=detail&aid=6553

Sergey Bushmanov
  • 23,310
  • 7
  • 53
  • 72
lupa
  • 101
  • 1
  • 3
1

Here is my solution. It works wells in Ubuntu 18.04

sudo apt-get install xorg 
sudo apt-get install libx11-dev 
sudo apt-get install libglu1-mesa-dev 
sudo apt-get install libatlas-base-dev
sudo apt-get install gfortran
sudo apt-get install libblas-dev liblapack-dev
sudo apt-get install libblas-dev
sudo apt install python-autopep8
sudo apt install libftgl2 libcgal-dev libglu1-mesa-dev libglu1-mesa-dev libx11-dev libfreetype6-dev
sudo apt-get install libcgal-dev libglu1-mesa-dev libglu1-mesa-dev

install.packages("digest") 
install.packages("xtable") 
install.packages("rgl") 
Shicheng Guo
  • 1,233
  • 16
  • 19
  • This answer contains many duplicate libraries in the list, for example libblas-dev, libglu-mesa-dev, etc. – bert Jun 27 '23 at 07:19