XQuartz and xorg-server

Ryan Schmidt ryandesign at macports.org
Sat Jan 23 08:11:54 UTC 2021

On Jan 20, 2021, at 17:32, Peter West wrote:

> I tried specifically building rgl from source. The source is available at https://cran.r-project.org/src/contrib/rgl_0.104.16.tar.gz.
> In R.app console, remove rgl package.
> > remove.packages(“rgl”)
> > install.packages(<path-to-source.tar.gz>, repos = NULL, type = “source”)

> It doesn’t find X, so it skips OpenGL; configure in the source needs tinkering.

I didn't have much luck with your command at first:

> install.packages("/tmp/rgl_0.104.16.tar.gz", repos = NULL, type = "source")
Warning in install.packages("/tmp/rgl_0.104.16.tar.gz", repos = NULL, type = "source") :
  'lib = "/opt/local/Library/Frameworks/R.framework/Versions/4.0/Resources/library"' is not writable
Would you like to use a personal library instead? (yes/No/cancel) y
Would you like to create a personal library
to install packages into? (yes/No/cancel) y
ERROR: dependencies ‘htmlwidgets’, ‘htmltools’, ‘knitr’, ‘jsonlite’, ‘shiny’, ‘magrittr’, ‘crosstalk’, ‘manipulateWidget’ are not available for package ‘rgl’
* removing ‘/Users/rschmidt/Library/R/4.0/library/rgl’
Warning message:
In install.packages("/tmp/rgl_0.104.16.tar.gz", repos = NULL, type = "source") :
  installation of package ‘/tmp/rgl_0.104.16.tar.gz’ had non-zero exit status

I found that I had to run

> install.packages("rgl")

which installed the dependencies first, and then rgl. In the configure output, I indeed see:

checking for X... no
configure: compiling without OpenGL support
configure: WARNING: X11 not found, continuing without OpenGL support.

It builds and installs, but evidently without X11 and OpenGL support.

I found the rgl source code at https://github.com/cran/rgl. I found in its configure.ac file that on macOS it explicitly adds /opt/X11 to the list of places where it looks for things. Since your X11 isn't there but is instead provided by MacPorts in /opt/local, you have to tell it that. It's pretty normal when building any software to have to tell it where the dependencies are. When you use MacPorts to build your software, we do this kind of thing for you so that any software you install with MacPorts can find any other software it needs that was also installed with MacPorts.

In the rgl readme, it mentions that the configure script supports these flags:

>   ----------------------------
>   --x-includes=<path>
>     X11 C header files include path
>   --x-libraries=<path>
>     X11 library linkage path

You can also learn this if you download the rgl source code manually, extract it, cd into its directory, and run ./configure --help.

I also found by searching that the r install.packages command accepts a configure.args argument for specifying arguments to pass to the configure script. So I tried this:

> install.packages("rgl", configure.args=c(rgl="--x-includes=/opt/local/include --x-libraries=/opt/local/lib"))

This failed:

configure: error: in `/private/var/folders/0_/y8x8nfkh8xj125006s6dfksh0000gp/T/RtmpUbm2PQ/R.INSTALL128833eb7f828/rgl':
configure: error: C compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘rgl’
* removing ‘/Users/rschmidt/Library/R/4.0/library/rgl’

Unfortunately I don't know why because I can't look in the config.log because I don't know where it is.

Another possibility might be:

> install.packages("rgl", configure.vars=c(rgl="CPPFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib"))

This would be a more general purpose solution that would work with any library dependencies, not just X11. But that failed the same way.

Perhaps these are problems specific to my computer and one of the above methods will work for you. If not, maybe you will know where r puts the build directory when it builds packages or, if it puts it in a temporary directory that it deletes automatically, how to tell it not to delete it so that we can have a look at it.

More information about the macports-users mailing list