wolff
wolff

Reputation: 113

udunits2 R install: udunits2.h not found

I'm trying to install udunits2 in R in order to satisfy the dependency for the ggforce package. However, the installer keeps failing on the check for udunits2. I have tried the instructions in this (udunits 2 devel is installed as shown here.) and this thread, which produces the same result as trying to install.packages('udunits2').

I was able to get it working on my Mint machine by just installing udunits2-dev, however I'm quite new to Fedora, and am not sure what is causing this.

System info:

Fedora 28, R-3.4.4

EDIT

Error output when trying to install using install.packages("udunits2", configure.args = "--with-udunits2-lib=/usr/bin/udunits2"):

* installing *source* package ‘udunits2’ ...
** package ‘udunits2’ successfully unpacked and MD5 sums checked
checking for gcc... gcc -m64
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 -m64 accepts -g... yes
checking for gcc -m64 option to accept ISO C89... none needed
checking for XML_ParserCreate in -lexpat... yes
checking how to run the C preprocessor... gcc -m64 -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking udunits2.h usability... no
checking udunits2.h presence... no
checking for udunits2.h... no
checking for ut_read_xml in -ludunits2... yes
-----Error: udunits2.h not found-----
     If the udunits2 library is installed in a non-standard location,
     use --configure-args='--with-udunits2-lib=/usr/local/lib' for example,
     or --configure-args='--with-udunits2-include=/usr/include/udunits2'
     replacing paths with appropriate values for your installation.
     You can alternatively use the UDUNITS2_INCLUDE and UDUNITS2_LIB
     environment variables.
     If udunits2 is not installed, please install it.
     It is required for this package.

Upvotes: 11

Views: 5779

Answers (3)

Kamil Slowikowski
Kamil Slowikowski

Reputation: 4614

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)

Upvotes: 4

weichen song
weichen song

Reputation: 85

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.

Upvotes: 1

Ralf Stubner
Ralf Stubner

Reputation: 26823

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/')

Upvotes: 4

Related Questions