Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
430 views
in Technique[技术] by (71.8m points)

r - Install udunits2 package for R3.3

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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...