Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install udunits2 package for R3.3

Tags:

r

I just wasted the whole day trying to figure out how to install the udunits2 package to be able to install the units package to be able to install the ggforce and ggraph packages.

I'm trying to install it on Ubuntu 16.04, and R >= 3.3 since ggforce was built under R 3.3.

I followed these instructions here: https://github.com/edzer/units/issues/1

Although I have libudunits-2.0 and udunits installed on my machine (as sudo apt-get install udunits2 doesn't find a udunits2 package), and the PATH to the libudunits-2 and udunits locations on my $PATH, in R when I try installing udunits2, units or ggforce I'm getting an error that says,

--* installing *source* package ‘udunits2’ ...
** package ‘udunits2’ 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 for XML_ParserCreate in -lexpat... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /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... no
-----Error: libudunits2.a 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.
     ERROR: configuration failed for package ‘udunits2’
* removing ‘/home/fjay/R/x86_64-pc-linux-gnu-library/3.3/udunits2’
* restoring previous ‘/home/fjay/R/x86_64-pc-linux-gnu-library 
/3.3/udunits2’

The downloaded source packages are in
    ‘/tmp/Rtmp0syxnJ/downloaded_packages’
Warning message:
In install.packages("udunits2", lib = "/home/fjay/R/x86_64-pc-linux-
 gnu-library/3.3") :
 installation of package ‘udunits2’ had non-zero exit status
>

So, umm, it's looking for the udunits2.h and libudunits2.a files.... So, I downloaded udunits2 from CRAN, unpacked it and put it in my R library. Then, if I put library(udunits2, lib.loc = "my library dir") I get an error saying it's not installed. So, when I install.package('udunits2', repo = NULL, libconfig.args = '--with-udunits2-lib=/home/fjay/R/x86_64-pc-linux-gnu-library/3.3') or install.packages('units',....) or install.packages('ggforce',...) it is still looking for these files...and, after inspection of the udunits2 package these files are not in any of the udunits2 folders.

If anyone knows how to install this udunits2 packages please help me!

like image 651
user2502338 Avatar asked Feb 17 '17 00:02

user2502338


3 Answers

I have installed the udunits2 package in R on the Linux platform (redhat) without Internet connnection.

I also had this problem.

Firstly, I installed the udunits2 (not the R package udunits2)in the Linux example at (/usr/include/udunits2).

Secondly, running this command worked: install.packages("udunits2_0.13.tar.gz",configure.args='--with-udunits2-include=/usr/include/udunits2')

I hope this experience could help you.

like image 35
gerryfocus Avatar answered Nov 18 '22 02:11

gerryfocus


I had the same problem. Following the first answer from here you have to install -dev version of udunits:

sudo apt-get install libudunits2-dev

Then the installation of udunits2 and ggforce goes without any error.

EDIT:

Following the comments below, for CentOS7 it should be:

sudo yum install udunits2-devel

And for MacOS:

brew install udunits
like image 200
potockan Avatar answered Nov 18 '22 01:11

potockan


This won't be any help to the chap that asked the question, but I was just having the same issue on a computing cluster without root access and the following worked:

homedir <- Sys.getenv("HOME")
udunits_dir <- file.path(Sys.getenv("HOME"), "udunits")
system(paste0("mkdir ", udunits_dir))
system(paste0("wget --directory-prefix=", udunits_dir, " ftp://ftp.unidata.ucar.edu/pub/udunits/udunits-2.2.25.tar.gz"))
owd <- getwd()
setwd(udunits_dir)
system("tar xzvf udunits-2.2.25.tar.gz")
setwd(file.path(udunits_dir, "udunits-2.2.25"))
system(paste0("./configure --prefix=", udunits_dir, "/local"))
system("make")
system("make install")
setwd(owd)
Sys.setenv(LD_LIBRARY_PATH=paste0(Sys.getenv("LD_LIBRARY_PATH"), ":", udunits_dir, "/local/lib"))
install.packages("udunits2", 
                 type = "source",
                 configure.args = c(paste0("--with-udunits2-include=", udunits_dir, "/local/include"), 
                                    paste0("--with-udunits2-lib=", udunits_dir, "/local/lib")),
                 repos = "http://cran.rstudio.com")
dyn.load(paste0(udunits_dir, "/local/lib/libudunits2.so.0"))
install.packages("units", repos = "http://cran.rstudio.com",
             configure.args = c(paste0("--with-udunits2-include=", udunits_dir, "/local/include"), 
                                paste0("--with-udunits2-lib=", udunits_dir, "/local/lib")))
like image 7
Florag Avatar answered Nov 18 '22 01:11

Florag