[Rd] How to get R to compile with PNG support

Karl-Dieter Crisman kcrisman at gmail.com
Mon Apr 18 17:48:40 CEST 2011


Dear R devel list,

Good morning; I'm with the Sage (http://www.sagemath.org) project.
(Some of you might have seen my talk on this at last summer's useR
conference).

We have some rudimentary support for using R graphics in various
cases, which has proved useful to many of our users who want to go
back and forth between R and other capabilities within Sage.
Unfortunately, the way we originally implemented this was using the
png and plot functions in R itself, which perhaps isn't the best
(i.e., everyone uses ggplot now? but I digress).

That means that when people download a binary of ours, or compile
their own, whether R's plot and png functions work depends heavily on
the rather obscure (to users) issue of exactly what headers are
present on the compiling machine.

Unfortunately, it is *very* unclear what actually needs to be present!
 There are innumerable places where this has come up for us, but
http://trac.sagemath.org/sage_trac/ticket/8868 and
http://ask.sagemath.org/question/192/compiling-r-with-png-support are
two of the current places where people have compiled information.

The FAQ says, "Unless you do not want to view graphs on-screen you
need ‘X11’ installed, including its headers and client libraries. For
recent Fedora distributions it means (at least) ‘libX11’,
‘libX11-devel’, ‘libXt’ and ‘libXt-devel’. On Debian we recommend the
meta-package ‘xorg-dev’. If you really do not want these you will need
to explicitly configure R without X11, using --with-x=no."

Well, we don't actually need to view graphs on-screen, but we do need
to be able to generate them and save them (as pngs, for instance) to
the correct directory in Sage for viewing.  But we have people who've
tried to do this in Ubuntu, with libpng and xorg-dev installed, and
the file /usr/include/X11/Xwindows.h exists, but all to no avail.
There are almost as many solutions people have found as there are
computers out there, it seems - slight hyperbole, but that's what it
feels like.

We've posted more than once (I think) to the r-help list, but have
gotten no useful feedback.  Is there *anywhere* that the *exact*
requirements R has for having

capabilities("png")
  png
FALSE

come out TRUE are documented?

Then, not only could we be smarter in how we compile R (currently
somewhat naively searching for /usr/include/X11/Xwindows.h to
determine whether we'll try for png support), but we would be able to
tell users something very precise to do (e.g., apt-get foo) if they
currently have R without PNG support in Sage.  Again, I emphasize that
apparently getting xorg-dev doesn't always do the trick.

We do realize that for most people wanting to use just R, it's best to
download a binary, which will behave nicely; Sage's "batteries
included" philosophy means that we are asking for more specialized
info from upstream, and for that I apologize in advance.  I also
apologize if I said something silly above, because I don't actually
know what all these files are - I've just looked into enough support
requests to have a decent idea of what's required.    We are trying
not to have to parse the makefile to figure all this out, and possibly
making some mistake there as well.

Thank you SO much for any help with this,
Karl-Dieter Crisman
for the Sage team



More information about the R-devel mailing list