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

From: Simon Urbanek <simon.urbanek_at_r-project.org>
Date: Thu, 21 Apr 2011 11:09:34 -0400

On Apr 20, 2011, at 8:35 AM, Karl-Dieter Crisman wrote:

>> Message: 12
>> Date: Wed, 20 Apr 2011 02:09:23 -0700 (PDT)
>> From: Sharpie <chuck_at_sharpsteen.net>
>> To: r-devel_at_r-project.org
>> Subject: Re: [Rd] How to get R to compile with PNG support
>> Message-ID: <1303290563237-3462502.post@n4.nabble.com>
>> Content-Type: text/plain; charset=UTF-8
>> 
>> 
>> 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.

>
> Good morning, Charlie et al.,
>
> Thanks for your words. We like R, too! We need to advertise it more,
> and this thread is part of making sure that happens in the long run.
>
> To the issue at hand. Our main concern is just not to have to spend
> hours reading the configuration and makefile to figure out exactly
> where things happen.
>
>
>>> 
>>> 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.

>
>
> True. It's the device enabling that I'm talking about. We enable
> aqua on Mac, and png on Linux.
>
> We ignore Cairo, and ignore X11 on Mac because it is too touchy (at
> least, according to the FAQ on this - different weird instructions for
> each type, and of course not everyone has X on Mac).
>

FWIW this seem a little outdated - all recent OS X come with X11 installed and libcairo is not a problem to build ...

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

>
> Great. That is okay with us; we aren't expecting (yet) people to be
> able to save R graphics in various output formats. Our native
> (matplotlib) graphics, we do expect this.
>
>
>>> 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.
>>> 

>
>
>> 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
>> 
>>  - configure didn't find Xlib as X11 is not listed under Interfaces
>>  - configure didn't find cairo as it is not listed under Additional
>> capabilities
>> 
>> 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.

>
> Gotcha. I suspect that the X11 not listed under Interfaces is the
> problem (again, we ignore Cairo).
>
> What is the *exact* file or directory that the R configure looks for
> in trying to list X11 under Interfaces? And is there any way around
> this at all? That is, is there any way for R to create but not
> display a graphic if it has (for instance) png support, like the one
> on the Trac ticket did? We can always just search for the png file
> and serve it up in our own viewers.
>
> Note that we already search for /usr/include/X11/Xwindows.h, and
> adding xorg-dev didn't help with the latest one (which may not be on
> the Trac ticket).
>

I missed which distro you're using, but xorg-dev is likely insufficient (by design). For example on Debian you'll also need libxt-dev. Note that your best friend is config.log and the output of configure - that tells *exactly* what you're missing. You will need at least X11, ICE, Xt libraries and X11/Intrinsic.h headers.

Cheers,
Simon

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

>
> Yes, I just referenced that for reference, as it were.
>
> Thank you, and I hope we can get this resolved!
>
> Karl-Dieter
>
> ______________________________________________
> R-devel_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>


R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 21 Apr 2011 - 15:13:37 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 Thu 21 Apr 2011 - 15:30:53 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