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

From: Sharpie <chuck_at_sharpsteen.net>
Date: Wed, 20 Apr 2011 02:09:23 -0700 (PDT)

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).

Thanks for stoping by Karl! I have to say that I am a big fan of the Sage project---it is a very good idea and I really appreciate all the time you guys put into it. I may not be able to answer all of your questions concerning PNG support, but hopefully some of the following pointers will be useful.

Karl-Dieter Crisman wrote:
>
> 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).
>

One important distinction to make is between R graphics functions such as plot and ggplot, and R graphics *devices*, such as png. The devices provide back ends that take the R-level function calls and actually execute the low-level "draw line from a to b, clip to rectangle A, insert left-justified text at x,y" primitives that get written to an output format.

Bottom line for Sage is that as long as you implement at least one device function, such as png, your users should be able to call plot, ggplot, and the rest of R's graphics functions to their heart's content, they just won't have a wide selection of output formats.

Karl-Dieter Crisman wrote:
>
> 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
>

In the trac ticket you linked, the configure output shows PNG is enabled (I.E. the library was found) but you may be ending up with no support for an actual png() graphics device due to one of the following

So, although R has the PNG library that is only useful for writing PNG files. R also needs the Xlib or Cairo libraries to provide drawing primitives that will create the figures those files will contain.

In the ask.sagemath question the problem appears to be that the user had X11 installed but not libpng.

I hope this helps!

-Charlie



Charlie Sharpsteen
Undergraduate-- Environmental Resources Engineering Humboldt State University
--
View this message in context: http://r.789695.n4.nabble.com/How-to-get-R-to-compile-with-PNG-support-tp3457938p3462502.html
Sent from the R devel mailing list archive at Nabble.com.

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Wed 20 Apr 2011 - 09:16:32 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 20 Apr 2011 - 16:50:49 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive