'RStudio aborts session when using rgl package

I am working with an 8 year old machine with Lubuntu 16.04.02. For some odd reason I couldn't install R the usual way so I compiled it and installed it from source. Here is my configure file command:

./configure --enable-R-shlib --with-blas --with-lapack --with-x=yes --enable-BLAS-shlib --with-tcltk

From terminal I can run with no problems

ejam@ejam:~/Documents/3ATD$ R

R version 3.4.1 (2017-06-30) -- "Single Candle"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-pc-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(rgl)
> open3d()
glX 
  1 
> x <- sort(rnorm(1000))
> y <- sort(rnorm(1000))
> z <- sort(rnorm(1000))+atan2(x,y)
> plot3d(x,y,z,col=rainbow(1000))
> 

However, when I try to run it in RStudio, the session is immediately aborted. It shows a message similar to the one shown here: R rgl Package crashes Rstudio

My R session log looks like:

R version 3.4.1 (2017-06-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.3 LTS

Matrix products: default
LAPACK: /usr/local/lib/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=es_MX.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=es_MX.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=es_MX.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=es_MX.UTF-8 LC_IDENTIFICATION=C       

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

loaded via a namespace (and not attached):
[1] compiler_3.4.1 tools_3.4.1   

Any help is appreciated.

EDIT 1:

I ran from terminal

$ gdb
(gdb) file rstudio

From the opened RStudio window, I typed

> library(rgl)
> open3d()

The session aborts immediately.

The terminal shows

Starting program: /usr/bin/rstudio 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffeac19700 (LWP 4288)]
[New Thread 0x7fffdc7c7700 (LWP 4289)]
[New Thread 0x7fffdbfc6700 (LWP 4290)]
[New Thread 0x7fffdb7c5700 (LWP 4291)]
[New Thread 0x7fffdafc4700 (LWP 4292)]
[Thread 0x7fffdafc4700 (LWP 4292) exited]
[New Thread 0x7fffdafc4700 (LWP 4319)]
[New Thread 0x7fffda7c3700 (LWP 4321)]
[New Thread 0x7fffd94d1700 (LWP 4325)]
[New Thread 0x7fffd8cd0700 (LWP 4326)]
[New Thread 0x7fff82026700 (LWP 4328)]
[New Thread 0x7fff81825700 (LWP 4329)]
load glyph failed err=6 face=0x1103500, glyph=2797
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
load glyph failed err=6 face=0x1103500, glyph=2797
libpng warning: iCCP: known incorrect sRGB profile
[Thread 0x7fffdb7c5700 (LWP 4291) exited]
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile


Solution 1:[1]

I think the problem is more general. I tried several examples from several nonstandard R libraries (I mean the libraries that do not come by default in R) such as 'rgl', 'kernlab' and 'TDA'. The funny thing is that I could flawlessly run these examples from terminal.

I admit I had some troubles trying to add the " --enable-BLAS-shlib" flag while configuring R source. I've recompiled R without such flag and RStudio now works as it should.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 EA304GT