R Cairo installation without apt-get, sudo
Asked Answered
C

3

17

I am working on a headless ubuntu machine with most of the cairo requirements preinstalled, but I am stumbling on getting R to use Cairo. Does anyone know what flags or additional packages I need to set/install in order to have install.packages build Cairo correctly with the existing installs of its dependencies? The tricks: I cannot use sudo commands or apt-get, and additional software must involve <50Mb of memory. Is this possible? It looks like most everything I need is present, if I can wire it into R.

> library('Cairo')
Error in library("Cairo") : there is no package called ‘Cairo’
> install.packages('Cairo')
...
* installing *source* package ‘Cairo’ ...
...
checking for pkg-config... /usr/bin/pkg-config
configure: CAIRO_CFLAGS=/usr/lib:/usr/bin:/usr/include
checking if R was compiled with the RConn patch... no
checking cairo.h usability... no
checking cairo.h presence... no
checking for cairo.h... no
configure: error: Cannot find cairo.h! Please install cairo (http://www.cairographics.org/) and/or set CAIRO_CFLAGS/LIBS correspondingly.
ERROR: configuration failed for package ‘Cairo’
* removing ‘/app/vendor/R/lib64/R/library/Cairo’

This means I need to install the libcairo2-dev package, but doing so via configure/make runs into a pixman error despite pixman being present on my system:

package pixman-1 was not found in the pkg-config search path.
Perhaps you should add the directory containing `pixman-1.pc'
to the PKG_CONFIG_PATH environment variable
No package 'pixman-1' found
No package 'pixman-1' found
checking whether cairo's image surface backend feature could be enabled
no (requires pixman-1 >= 0.22.0 http://cairographics.org/releases/)error: mandatory image surface backend feature could not be enabled

What is installed:

$ dpkg -l | grep 'cairo\|png\|fontc\|pix'
ii  fontconfig     2.8.0-2ubuntu1 generic font configuration library - support
ii  fontconfig-con 2.8.0-2ubuntu1 generic font configuration library - configu
ii  libcairo2      1.8.10-2ubuntu The Cairo 2D vector graphics library
ii  libfontconfig1 2.8.0-2ubuntu1 generic font configuration library - runtime
ii  libpixman-1-0  0.16.4-1ubuntu pixel-manipulation library for X and cairo
ii  libpng12-0     1.2.42-1ubuntu PNG library - runtime
ii  libpng12-dev   1.2.42-1ubuntu PNG library - development

My session info:

> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=C                 LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base   

R does not see cairo:

> 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 
Coumarin answered 21/5, 2013 at 20:28 Comment(4)
You probably need the development package libpixman-1-dev as well.Trawler
If you just need cairo.h, why are you building cairo yourself instead of just installing libcairo2-dev?Buchmanism
As the second block of text indicates, I am trying to install that package, but hitting a dependency error. The commenter above was correct in pixman needing development headers as well.Coumarin
@bwarren did you manage to fix this issue I have the same problem using an AWS R instance.Anaglyph
B
37

you need the cario dev files

apt-get install libcairo2-dev

I also needed to install the following

apt-get install libxt-dev

For a solution which does not use apt (as the OP requested), please see the following answer

Butcherbird answered 29/7, 2014 at 11:42 Comment(2)
Requires apt-get and sudo, which the title notes are unavailable. The more definitive answer on this process is https://mcmap.net/q/744181/-heroku-rpy-rhome-discovery/…Coumarin
I still get this problem in 2023 and your suggestion solve my problem. ThanksLuau
A
1

Looks like you need cario-devel. See below for instructions for installation. At least doing so resolved my missing "cairo.h" issue. Hope this helps.

http://cairographics.org/download/

Antependium answered 23/1, 2014 at 20:19 Comment(0)
G
-6

Follow these steps

sudo apt-get install libcairo2-dev

Once installed, you can execute following commands in R-Studio

install.packages('Cairo')
library(Cairo)
Gunnel answered 19/11, 2015 at 15:16 Comment(1)
This question (which is pretty old now) says without sudo or apt-getBolen

© 2022 - 2024 — McMap. All rights reserved.