udunits2 R install: udunits2.h not found
On Fedora the header file is installed in /usr/include/udunits2
, c.f. this Github issue. Solution provided there:
sudo yum install udunits2-devel
Followed by:
install.packages("udunits2",configure.args='--with-udunits2-include=/usr/include/udunits2/')
Get the source code for udunits2 from the website: ftp://ftp.unidata.ucar.edu/pub/udunits
Download, compile, and install udunits2:
# Download the library
wget ftp://ftp.unidata.ucar.edu/pub/udunits/udunits-2.2.26.tar.gz
# Decompress the archive
tar xf udunits-2.2.26.tar.gz
# Navigate to the archive
cd ./udunits-2.2.26
# Configure the build for your system
./configure prefix=$HOME/.local
# Use 4 jobs to build quickly
make -j 4
# Install to our prefix
make install
Start a new R session and install the udunits2
R package:
(Make sure to change $HOME
to your actual home path)
install.packages(
"udunits2",
configure.args = '--with-udunits2-include=$HOME/.local/include/'
)
Tested on this system:
R version 3.4.0 (2017-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server release 6.5 (Santiago)
As a supercomputer server user without permission of sudo yum, I found installing udunits2-devel quite diffcult. Alternatively, i found spack https://spack.readthedocs.io/en/latest/basic_usage.html quite useful for installing udunits2&units R packages:
spack install r-udunits2
spack install r-units
Spack will automatically install dependent packages, and i don't have to install udunits2-devel by myself. Since i installed units R package for ggforce R package, and ggforce can't be installed by spack, i need to load units before entering R and then install ggforce:
$source <(spack module tcl loads r-units)
$source <(spack module tcl loads r-udunits2)
$R
>install.packages("ggforce")
and everything worked well.