Homebrew R build missing Cairo

2020-03-03 07:41发布

问题:

I installed R on an OSX 10.7.5 server using brew:

brew install R

Everything seems so OK far, however Cairo is not working:

> svg(tempfile())
Warning messages:
1: In svg(tempfile()) :
  unable to load shared object '/usr/local/Cellar/r/2.15.2/R.framework/Resources/library/grDevices/libs//cairo.so':
  dlopen(/usr/local/Cellar/r/2.15.2/R.framework/Resources/library/grDevices/libs//cairo.so, 6): image not found
2: In svg(tempfile()) : failed to load cairo DLL

The shared object file seems to be missing completely:

id-86-243:Resources jeroen$ ls -ltr library/grDevices/libs/
total 488
-rwxrwxr-x  1 jeroen  admin  245764 Dec 22 17:03 grDevices.so

I rarely use OSX, so I am not quite sure if this is a bug in this particular distribution of R, or if I have done something wrong when building it?

回答1:

I just ran into this problem. It seems to be a problem with pkg-config locating cairo during the R configure stage. The workaround seems to be:

export PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig

so that R can properly use cairo.

I install R directly from source, rather than with homebrew, but I do use homebrew to keep other libraries up to date. This resolves the problem for me.

For reference, I am running OSX Mavericks.