R Cairo package installation failed in Ubuntu 18.04 - r

I attempt to install Cairo package in R under a Docker Ubuntu 18.04 container. Before installing the R Cairo package, I installed these packets in Ubuntu: libgtk2.0-dev, libcairo2-dev, xvfb, xauth, xfonts-base, r-base-dev, and libxt-dev.
However, when I installed Cairo package in R, I got the following error:
checking if R was compiled with the RConn patch... no
checking cairo.h usability... yes
checking cairo.h presence... yes
checking for cairo.h... yes
checking for PNG support in Cairo... yes
checking for ATS font support in Cairo... no
configure: CAIRO_LIBS=-lfreetype -lz -lpng16 -lz -lcairo -lXext -lXrender -lX11
checking for library containing deflate... no
checking whether Cairo programs can be compiled... configure: error: Cannot
compile a simple Cairo program. See config.log for details.
ERROR: configuration failed for package ‘Cairo’
* removing ‘/opt/conda/lib/R/library/Cairo’
The downloaded source packages are in
‘/tmp/RtmprETcPh/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("Cairo") :
installation of package ‘Cairo’ had non-zero exit status
I've checked /tmp/RtmprETcPh/downloaded_packages, and there is only a filed called Cairo_1.5-9.tar.gz. And I don't know where to find config.log for more compile details of compiling a simple Cairo program.
Please help me to resolve out this issue if anybody know how to resolve out this issue.
Thank you

You may need to install the x11 dev libs since the docker container is likely not running these.
Try
sudo apt-get install libx11-dev

Under ubuntu 20.04, after installing libx11-dev, trying to install Cairo gave the error X11/Intrinsic.h not found. This is in libxt-dev. After installing this, Cairo could be installed.

Related

rgdal installed in Ubuntu 18.04 LTS, but R 3.5 not recognized it

I am trying to install 'rdgal' package in R 3.5 (Ubuntu 18.04), however, R shows this error:
configure: R_HOME: /opt/R/3.5.3/lib/R
configure: CC: gcc
configure: CXX: g++
configure: C++11 support available
configure: rgdal: 1.4-7
checking for /usr/bin/svnversion... yes
configure: svn revision: 845
checking for gdal-config... no
no
configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package ‘rgdal’
* removing ‘/home/sergiob/R/x86_64-pc-linux-gnu-library/3.5/rgdal’
The downloaded source packages are in
‘/tmp/Rtmp0rrlnK/downloaded_packages’
Warning message:
In install.packages("rgdal") :
installation of package ‘rgdal’ had non-zero exit status
However, GDAL seems to be installed in the system, using gdalinfo --version
GDAL 2.2.3, released 2017/11/20
and using dpkg -l | grep gdal | cut -c-72 (seems that Ubuntu have two versions: 2.2 and 2.4)
ii gdal-bin 2.2.3+dfsg-2
ii gdal-data 2.4.2+dfsg-1~bionic0
ii libgdal20 2.2.3+dfsg-2
ii python-gdal 2.2.3+dfsg-2
ii python3-gdal 2.2.3+dfsg-2
Also, I have installed QGIS 3.13 (with a GDAL/ORG 2.2.3) but I cannot identify if this is the real problem.
I tried to re-install all dependencies and packages, including sudo apt-get install libgdal-dev libproj-dev, but not solve nothing.
I tried to review all posts about this issue, however, I can solve this problem yet.
Thre are a way to R to recognize the GDAL installed in Ubuntu 18.04?
The solution was to uninstall QGIS, and install GDAL first and re-install QGIS after.
Finally, the rGDAL was possible to be installed in R.

Ubuntu 14.04 configure: error: "libxml not found"

Trying to install the XML package as follows I get the error configure: error: "libxml not found". It seems that R is picking up the libxml2 installation from Anaconda. How can I fix this?
R version 3.4.4 (2018-03-15) -- "Someone to Lean On"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
> install.packages("XML")
Installing package into ‘/home/bravegag/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/XML_3.98-1.19.tar.gz'
Content type 'application/x-gzip' length 1600788 bytes (1.5 MB)
==================================================
downloaded 1.5 MB
* installing *source* package ‘XML’ ...
** package ‘XML’ successfully unpacked and MD5 sums checked
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for sed... /bin/sed
checking for pkg-config... /usr/bin/pkg-config
checking for xml2-config... /opt/dev/anaconda/2018.12/bin/xml2-config
USE_XML2 = yes
SED_EXTENDED_ARG: -E
Minor 9, Patch 8 for 2.9.8
Located parser file -I/opt/dev/anaconda/2018.12/include/libxml2 -I/opt/dev/anaconda/2018.12/include/parser.h
Checking for 1.8: -I/opt/dev/anaconda/2018.12/include/libxml2 -I/opt/dev/anaconda/2018.12/include
Using libxml2.*
checking for gzopen in -lz... yes
checking for xmlParseFile in -lxml2... no
checking for xmlParseFile in -lxml... no
configure: error: "libxml not found"
ERROR: configuration failed for package ‘XML’
* removing ‘/home/bravegag/R/x86_64-pc-linux-gnu-library/3.4/XML’
The downloaded source packages are in
‘/tmp/RtmpannHh6/downloaded_packages’
Warning message:
In install.packages("XML") :
installation of package ‘XML’ had non-zero exit status
>
I also get this:
$ type xml2-config
xml2-config is /opt/dev/anaconda/2018.12/bin/xml2-config
but setting the config in the R environment doesn't help:
Sys.setenv(XML_CONFIG="/opt/dev/anaconda/2018.12/bin/xml2-config")
UPDATE I already had libxml2 installed in the system see:
bravegag#zeus:~$ sudo apt-get install libxml2
Reading package lists... Done
Building dependency tree
Reading state information... Done
libxml2 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
bravegag#zeus:~$ sudo apt-get install libxml2-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libxml2-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
Make sure your system has the libxml-dev or libxml2-dev package installed. i.e.
sudo apt-get install libxml2-dev
I'm unable to determine which is the right version (libxml or libxml2) for 14.04 but you'll want to make sure you have the -dev version installed.
I had the same error but libxml2-dev was already installed so that didn't help.
What did help was to install libxml through conda using
conda install r-xml
I think there is a problem with the environment variables when you install R through conda.

Problem with R package installation: sf; system library not found

I am trying to install the R package sf. It mentions the system dependencies GDAL, GEOS and PROJ.4. I have installed all of these using
$sudo apt-get install libgdal-dev libgeos-dev libproj-dev proj-bin
However sf still complains that it is missing (something from?) the libraries:
$sudo R CMD INSTALL sf_0.6-3.tar.gz
[...]
configure: pkg-config proj exists, will use it
checking proj_api.h usability... yes
checking proj_api.h presence... yes
checking for proj_api.h... yes
configure: PROJ: 4.9.2
checking for pj_init_plus in -lproj... no
configure: error: libproj not found in standard or given locations.
ERROR: configuration failed for package ‘sf’
The same goes for using the install.packages("sf") command in R. I am using R version 3.5.0 on an Ubuntu 16.04 system, I managed to install the package on another computer with R version 3.4.3 but don't know what I did different to make it work then. Both apt and pkg-config --modversion proj say that the version is higher than needed (4.9.2) and i tried to find some info that could help me resolve the problem using pkg-config or on the internet but couldn't find anything. I did find the following line in /usr/include/proj_api.h (found using sudo apt-file search proj_api.h):
projPJ pj_init_plus(const char *);
which mentions the thing in the check not found, but I don't understand in what way it relates to this.
As a note, I do have two versions of R installed, I also have version 3.2.3 on the computer. Could this be a source of the problem? (I am sure, that the version I am installing the sf package to is 3.5)
EDIT
I have found another R package (proj4) with the libproj dependency and tried to install that one. While it did stop at the same error, this one gave a longer message:
>install.packages("proj4")
[...]
checking proj_api.h usability... yes
checking proj_api.h presence... yes
checking for proj_api.h... yes
checking for pj_init_plus in -lproj... no
configure: error: libproj and/or proj_api.h not found in standard search locations.
*** Install PROJ.4 and if necessary set PKG_CPPFLAGS/PKG_LIBS accordingly.
ERROR: configuration failed for package ‘proj4’
The PKG_CPPFLAGS/PKG_LIBS variables? are not found in R, and echo $PKG_LIBS showed nothing either. Might there be a way I could set these so that the packages can be installed?
I am thankful for any tips or hints as to what causes this.
Peter
I think you may be using older versions of libgdal-dev and you
the following question could be the issue you are seeing
Rgdal installation failed on ubuntu 16.04
sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable
sudo apt update
sudo apt install gdal-bin python-gdal python3-gdal libgdal1-dev

Problems Installing rgeos and rgdal on Mac OS X High Sierra

I have looked at the multiple sources to figure out how to install rgeos and rgdal on Mac OS X High Sierra in a way that works with Anaconda Navigator. I mention Anaconda because I want to be able to build static project-specific, package environments to ensure that my projects work 6 months from now when the dependent packages change. I have successfully installed and used both rgeos and rgdal on a couple other computers but seem to be having issues on a new computer. I want to launch Shiny apps from Anaconda Navigator's RStudio. None of the solutions I found, listed below, worked:
https://dyerlab.ces.vcu.edu/2015/03/31/install-rgeos-on-osx/
https://cran.rstudio.com/web/packages/rgeos/rgeos.pdf
http://tlocoh.r-forge.r-project.org/mac_rgeos_rgdal.html
https://anaconda.org/conda-forge/r-rgdal
Based on the above sources and my slow progression through a series of error messages, I tried the following:
Install GDAL 2.2 Complete [30.0 MiB] 2018-3-10 from http://www.kyngchaos.com/software/frameworks. This installs GDAL, GEOS, PROJ, SQLite and UnixImageIO frameworks.
The above installed without an error message. But attempting to install rgeos gave an error message:
configure: error: geos-config not found or not executable.
Consequently, either the install failed and didn't notify me, or there is some type of $PATH issue (?). On a blog, someone suggested to do the following in response to the aforementioned issue:
brew install geos
The above completed successfully. So I went into RStudio and tried the following, which resolved the former error but produced a new one:
install.packages("~/Downloads/rgeos_0.3-28.tar.gz", repos = NULL, type = "source")
installing source package ‘rgeos’ ...
configure: CC: x86_64-apple-darwin13.4.0-clang
configure: CXX: x86_64-apple-darwin13.4.0-clang++
configure: rgeos: 0.3-28
checking for /usr/bin/svnversion... yes
cat: inst/SVN_VERSION: No such file or directory
configure: svn revision:
checking for geos-config... /usr/local/bin/geos-config
checking geos-config usability... yes
configure: GEOS version: 3.6.2
checking geos version at least 3.2.0... yes
checking geos-config clibs... yes
checking geos_c.h presence and usability... no
configure: error: geos_c.h not found in standard or given locations.
ERROR: configuration failed for package ‘rgeos’
removing ‘/Users/aloha2018/anaconda2/lib/R/library/rgeos’
Warning in install.packages :
installation of package ‘/Users/aloha2018/Downloads/rgeos_0.3-28.tar.gz’ had non-zero exit status
Any ideas on what to try next?
Naturally, I already tried in an RStudio application launched from Anaconda Navigator:
install.packages("rgeos")
install.packages("rgdal")
both from CRAN and from tar.gz. But it seems like it is unable to find a file called geos_c.h, which does indeed exist on my computer at:
/Library/Frameworks/GEOS.framework/Versions/3B/Headers/geos_c.h
Is there a way to tell RStudio to look in the directory containing that file so my rgeos and rgdal installations work? Are there other errors I should expect to encounter and if so, how do I avoid/resolve them?
I also tried in a Terminal window:
conda install -c conda-forge r-rgdal
but that fails after spending a long time attempting to "solve environment":
Andrews-MacBook-Pro:~ aloha2018$ conda install -c conda-forge r-rgdal
Solving environment: failed
UnsatisfiableError: The following specifications were found to be in conflict:
- r-rgdal
- rstudio==1.1.423
Use "conda info <package>" to see the dependencies for each package.
So I try:
conda r-rgdal
But there is no output:
Andrews-MacBook-Pro:~ aloha2018$ conda info r-rgdal
Andrews-MacBook-Pro:~ aloha2018$
I've had a similar issue. I first solved it by installing everything using conda using the following environment.yml configuration
name: london-crime-r
channels:
- conda-forge
- conda
dependencies:
- gdal
- geos
- r-base
- r-rcpp
- r-irkernel
- r-mass
- r-dplyr
- r-rgdal
- r-rgeos
- r-raster
- rstudio
However, after updating conda, resolving dependencies did not finish within the 10 hours so I went the traditional route:
Use brew to install geos and gdal. It takes 40 minutes to build on my machine.
brew install geos gdal
Once that has been achieved, install R packages in this sequence.
install.packages('sp', type='source')
install.packages("rgeos", repos="http://R-Forge.R-project.org", type="source")
require(rgeos)
install.packages("rgdal", repos="http://R-Forge.R-project.org", type="source")
require(rgdal)
Subsequently, the packages below are ok with the plain install.
libraries <- c("rgdal",
"rgeos",
"raster",
"spdep",
"spatstat")
install.packages(libraries)

Install R cairo package after installing cairo via conda

I'm trying to install the Cairo package for R. I don't have admin rights for the server so I installed Cairo via the conda package manager conda install -c https://conda.anaconda.org/anaconda cairo. I have compiled R from source in my home directory.
I have tried to add the following to my bashrc:
export CAIRO_LIBS=-L${HOME}/miniconda/pkgs/cairo-1.12.18-6/lib/cairo/
export CAIRO_CFLAGS=-I${HOME}/miniconda/pkgs/cairo-1.12.18-6/include/cairo/
When I try install.packages('Cairo'), I get the following error:
configure: CAIRO_CFLAGS=-I/N/u/jfreimer/Mason/miniconda/pkgs/cairo-1.12.18-6/include/cairo/
checking if R was compiled with the RConn patch... no
checking cairo.h usability... yes
checking cairo.h presence... yes
checking for cairo.h... yes
checking for PNG support in Cairo... yes
checking for ATS font support in Cairo... no
configure: CAIRO_LIBS=-L/N/u/jfreimer/Mason/miniconda/pkgs/cairo-1.12.18-6/lib/cairo/
checking for library containing deflate... -lz
checking whether Cairo programs can be compiled... configure: error: Cannot compile a simple Cairo program. See config.log for details.
ERROR: configuration failed for package ‘Cairo’
* removing ‘/N/home/j/f/jfreimer/Mason/R/lib64/R/library/Cairo’
Anaconda has an R package of cairo (https://anaconda.org/r/r-cairo) so all of the dependencies that I need should be installable via conda. However, I am trying to use the standalone R that I installed and not conda R as I have had trouble with other packages in conda R. I was wondering if anyone has any suggestions
try:
R -e "install.packages('cairo')" --configure-vars=
"CAIRO_CFLAGS=/PATH_TO_CAIRO/include/cairo;
CAIRO_LIBS=/PATH_TO_CAIRO/lib/cairo"
This work for me.
I had similar issues. I solved it by simply uninstalling and re-installing.
Open up R in the terminal console:
R
Uninstall Cairo
remove.packages("Cairo")
Re-install:
install.packages("Cairo")

Resources