udunits2 R安装:找不到udunits2.h

时间:2018-05-16 03:47:50

标签: r

我正在尝试在R中安装udunits2以满足ggforce包的依赖性。但是,安装程序在检查udunits2时仍然失败。我已经尝试了this中的说明(如图所示安装了udunits 2 devel here。) 和this线程,它使same result产生install.packages('udunits2')

我能够通过安装udunits2-dev让我的Mint机器工作,但是我对Fedora很新,并且不确定是什么导致了这个。

系统信息:

Fedora 28,R-3.4.4

修改

尝试使用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.

3 个答案:

答案 0 :(得分:3)

在Fedora上,头文件安装在/usr/include/udunits2,c.f。这Github issue。在那里提供解决方案:

sudo yum install udunits2-devel

其次是:

install.packages("udunits2",configure.args='--with-udunits2-include=/usr/include/udunits2/')

答案 1 :(得分:2)

从以下网站获取udunits2的源代码:ftp://ftp.unidata.ucar.edu/pub/udunits

下载,编译和安装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

# 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

启动新的R会话并安装udunits2 R软件包:

(请确保将$HOME更改为您的实际家庭路径)

install.packages(
  "udunits2",
   configure.args = '--with-udunits2-include=$HOME/.local/include/'
)

在此系统上测试过:

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)

答案 2 :(得分:1)

作为未经 sudo yum 许可的超级计算机服务器用户,我发现安装udunits2-devel非常困难。另外,我发现spack https://spack.readthedocs.io/en/latest/basic_usage.html 对于安装udunits2&units R软件包非常有用:

spack install r-udunits2
spack install r-units

Spack将自动安装相关的软件包,而我不必自己安装udunits2-devel。 由于我已为ggforce R软件包安装了Units R软件包,而spack无法安装ggforce,因此我需要在输入R之前先加载设备,然后再安装ggforce:

$source <(spack module tcl loads r-units)
$source <(spack module tcl loads r-udunits2)
$R
>install.packages("ggforce")

一切都很好。