首页 > 解决方案 > 在 Ubuntu 18.04LTS 上在 R 中安装 OpenMx 包

问题描述

尝试install.packages("OpenMx")在 Ubuntu 18.04 上的 R 中安装 () OpenMx 时出现以下错误。我不熟悉编译 C 代码,所以我请你为我“简化一下”。

Installing package into ‘/home/adam/R/x86_64-pc-linux-gnu-library/3.5’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/OpenMx_2.12.1.tar.gz'
Content type 'application/x-gzip' length 3338967 bytes (3.2 MB)
==================================================
downloaded 3.2 MB

* installing *source* package ‘OpenMx’ ...
** package ‘OpenMx’ successfully unpacked and MD5 sums checked
NOTE: ./configure is not an autoconf generated script.
Change default C/C++ compiler and default compile flags by editing ~/.R/Makevars
** libs
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG  -I"/home/adam/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -I"/home/adam/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include" -I"/home/adam/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include" -I"/home/adam/R/x86_64-pc-linux-gnu-library/3.5/BH/include" -I"/home/adam/R/x86_64-pc-linux-gnu-library/3.5/rpf/include"   -fopenmp     -I. -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-i39faS/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c Compute.cpp -o Compute.o
In file included from omxState.h:31:0,
                 from glue.h:23,
                 from Compute.cpp:24:
omxDefines.h:247:10: fatal error: Eigen/Core: No such file or directory
 #include <Eigen/Core>
          ^~~~~~~~~~~~
compilation terminated.
/usr/lib/R/etc/Makeconf:171: recipe for target 'Compute.o' failed
make: *** [Compute.o] Error 1
ERROR: compilation failed for package ‘OpenMx’
* removing ‘/home/adam/R/x86_64-pc-linux-gnu-library/3.5/OpenMx’
* restoring previous ‘/home/adam/R/x86_64-pc-linux-gnu-library/3.5/OpenMx’
Warning in install.packages :
  installation of package ‘OpenMx’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/RtmpbljrRR/downloaded_packages’

更新 1

看起来该错误实际上可能是RcppEigen未安装软件包的结果。当我尝试安装软件包时,我收到 10,000 行错误消息。这是第一个:

g++  -I"/usr/share/R/include" -DNDEBUG  -I"/home/adam/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include"   -I../inst/include -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-i39faS/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c RcppEigen.cpp -o RcppEigen.o
In file included from ../inst/include/Eigen/Core:392:0,
                 from ../inst/include/Eigen/Dense:1,
                 from ../inst/include/RcppEigenForward.h:30,
                 from ../inst/include/RcppEigen.h:25,
                 from RcppEigen.cpp:22:
../inst/include/Eigen/src/Core/arch/SSE/PacketMath.h:60:39: warning: ignoring attributes on template argument ‘__m128 {aka __vector(4) float}’ [-Wignored-attributes]
 template<> struct is_arithmetic<__m128>  { enum { value = true }; };

更新 2

我已经RcppEigen成功安装,但OpenMx仍然无法编译。唯一的错误是在很长(数千行)的编译警告流的末尾。错误:ERROR: compilation failed for package 'OpenMx'

标签: rgccg++ubuntu-18.04openmx

解决方案


这里出了点问题,您只显示部分输出无济于事。

对于初学者,该软件包显然依赖于其他二进制软件包,但您没有告诉我们是否安装了这些软件包。 如果您之前有没有显示的错误,那么简单地说,您就没有机会安装 OpenMX。

所以我会做以下事情:确保上面和下面链接中的所有软件包都已安装。通过例如,通过 R 一个一个地加载它们来测试它。Imports:LinkingTo:library(Rcpp)

如果满足所有要求,然后尝试安装 OpenMX,并更新您的问题将相关的错误消息(如果有)。但简而言之,上面关于该libeigen3-dev软件包的评论完全具有误导性,因为RcppEigen它没有使用该软件包。

最后,该r-sig-debian列表友好且耐心,是 Debian/Ubuntu 问题的地方。

编辑:根据 OP 的编辑,一个快捷方式可能是sudo apt-get install r-cran-rcppeigen.


推荐阅读