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
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 - 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. 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.
> 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 at 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).> 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).> 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
Followup with the specific issue in our most recent (non-posted, as of yet) attempts on a certain box. We now have xorg-dev, libcairo-dev, and Xwindows.h and libpng (as below) on this machine, but R is not compiling with support for any of these things. Once again, any help knowing *exactly* what to pass to the configuration script or anything else would be *greatly* appreciated. We are planning to use R in Sage on several occasions with this machine this summer if we can get this going (see http://www.maa.org/prep/2011/sage.html). ++++ R is now configured for i686-pc-linux-gnu Source directory: . Installation directory: /home/sageserver/sage/local C compiler: gcc -std=gnu99 -I/home/sageserver/sage/local/include -L/home/sageserver/sage/local/lib/ Fortran 77 compiler: sage_fortran -g -O2 C++ compiler: g++ -g -O2 Fortran 90/95 compiler: sage_fortran -g -O2 Obj-C compiler: Interfaces supported: X11 External libraries: readline, BLAS(ATLAS), LAPACK(generic) Additional capabilities: PNG, NLS Options enabled: shared R library, R profiling Recommended packages: yes However:> capabilities()jpeg png tiff tcltk X11 aqua http/ftp sockets FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE libxml fifo cledit iconv NLS profmem cairo TRUE TRUE TRUE TRUE TRUE FALSE FALSE
On 04/19/2011 05:00 AM, r-devel-request at r-project.org wrote:> Date: Mon, 18 Apr 2011 11:48:40 -0400 > From: Karl-Dieter Crisman<kcrisman at gmail.com> > To:r-devel at r-project.org > Cc: Jason Grout<jason.grout at drake.edu> > Subject: [Rd] How to get R to compile with PNG support > Message-ID:<BANLkTinQz7eOE7b-GpBRcNRhcY0-bdc4Eg at mail.gmail.com> > Content-Type: text/plain; charset=windows-1252 > > 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?I had a similar question some time ago. The answer (of course) is in the code and configure macros. The main logic is in src/main/platform.c::do_capabilities: SET_STRING_ELT(ansnames, i, mkChar("png")); #ifdef HAVE_PNG # if defined Unix && !defined HAVE_WORKING_CAIRO LOGICAL(ans)[i++] = X11; # else /* Windows */ LOGICAL(ans)[i++] = TRUE; # endif #else LOGICAL(ans)[i++] = FALSE; #endif ------------------------------- From m4/R.m4: if test "${use_libpng}" = yes; then AC_CHECK_LIB(z, main, [have_png=yes], [have_png=no]) if test "${have_png}" = yes; then _R_HEADER_PNG have_png=${r_cv_header_png_h} fi if test "${have_png}" = yes; then AC_CHECK_LIB(png, png_create_write_struct, [have_png=yes], [have_png=no], [-lz ${LIBS}]) fi if test "${have_png}" = yes; then BITMAP_LIBS="${BITMAP_LIBS} -lpng -lz" AC_DEFINE(HAVE_PNG, 1, [Define if you have the PNG headers and libraries.]) fi fi --------------------------------------- HAVE_WORKING_CAIRO is set by m4/cairo.m4. However, the PNG function doesn't consult capabilities("png"). Presumably capabilities("png") is sufficient, but you'll have to pick up the trail in the png function to find out what's really going on. I've had good outcomes with cairo.> 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 > >-- Matthew S Shotwell Assistant Professor School of Medicine Department of Biostatistics Vanderbilt University