r - 无法在 R 中编译 RcppArmadillo

标签 r rcpp

我在编译 RcppArmadillo 时遇到问题。这是我尝试安装软件包时的结果:

 > install.packages("RcppArmadillo")
Installing package(s) into ‘/home/*****/R/i686-pc-linux-gnu-library/2.15’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/RcppArmadillo_0.3.4.4.tar.gz'
Content type 'application/x-gzip' length 742125 bytes (724 Kb)
opened URL
==================================================
downloaded 724 Kb

Loading required package: survival
Loading required package: stats
Loading required package: utils
Loading required package: graphics
Loading required package: splines
Hmisc library by Frank E Harrell Jr

Type library(help='Hmisc'), ?Overview, or ?Hmisc.Overview')
to see overall documentation.

NOTE:Hmisc no longer redefines [.factor to drop unused levels when
subsetting.  To get the old behavior of Hmisc type dropUnusedLevels().


Attaching package: ‘Hmisc’

The following object(s) are masked from ‘package:survival’:

    untangle.specials

The following object(s) are masked from ‘package:base’:

    format.pval, round.POSIXt, trunc.POSIXt, units


    Welcome at Sun Dec  2 18:54:49 2012 
    * installing *source* package ‘RcppArmadillo’ ...
    ** package ‘RcppArmadillo’ successfully unpacked and MD5 sums checked
    ** libs
    g++ -I/usr/share/R/include -DNDEBUG   -I"/home/******/R/i686-pc-linux-gnu-library/2.15/Rcpp/include"  -I../inst/include -fpic  -O3 -pipe  -g  -c RcppArmadillo.cpp -o RcppArmadillo.o
    g++ -I/usr/share/R/include -DNDEBUG   -I"/home/******/R/i686-pc-linux-gnu-library/2.15/Rcpp/include"  -I../inst/include -fpic  -O3 -pipe  -g  -c fastLm.cpp -o fastLm.o
    Loading required package: survival
    Loading required package: stats
    Loading required package: utils
    Loading required package: graphics
    Loading required package: splines
    Hmisc library by Frank E Harrell Jr

    Type library(help='Hmisc'), ?Overview, or ?Hmisc.Overview')
    to see overall documentation.

    NOTE:Hmisc no longer redefines [.factor to drop unused levels when
    subsetting.  To get the old behavior of Hmisc type dropUnusedLevels().


    Attaching package: ‘Hmisc’

    The following object(s) are masked from ‘package:survival’:

        untangle.specials

    The following object(s) are masked from ‘package:base’:

        format.pval, round.POSIXt, trunc.POSIXt, units

    g++ -shared -o RcppArmadillo.so RcppArmadillo.o fastLm.o Welcome at Sun Dec 2 18:55:06 2012
-L/home/******/R/i686-pc-linux-gnu-library/2.15/Rcpp/lib -lRcpp -Wl,-rpath,/home/******/R/i686-pc-linux-gnu-library/2.15/Rcpp/lib -llapack -lblas -lgfortran -lm -lquadmath -L/usr/lib/R/lib -lR
    Loading required package: survival
    Loading required package: stats
    Loading required package: utils
    Loading required package: graphics
    Loading required package: splines
    Hmisc library by Frank E Harrell Jr

    Type library(help='Hmisc'), ?Overview, or ?Hmisc.Overview')
    to see overall documentation.

    NOTE:Hmisc no longer redefines [.factor to drop unused levels when
    subsetting.  To get the old behavior of Hmisc type dropUnusedLevels().


    Attaching package: ‘Hmisc’

    The following object(s) are masked from ‘package:survival’:

        untangle.specials

    The following object(s) are masked from ‘package:base’:

        format.pval, round.POSIXt, trunc.POSIXt, units
        g++: error: Welcome: No such file or directory
        g++: error: at: No such file or directory
        g++: error: Sun: No such file or directory
        g++: error: Dec: No such file or directory
        g++: error: 2: No such file or directory
        g++: error: 18:55:08: No such file or directory
        g++: error: 2012: No such file or directory
        make: *** [RcppArmadillo.so] Error 1
        ERROR: compilation failed for package ‘RcppArmadillo’
        * removing ‘/home/****/R/i686-pc-linux-gnu-library/2.15/RcppArmadillo’
        Warning in install.packages :
          installation of package ‘RcppArmadillo’ had non-zero exit status

        The downloaded source packages are in
            ‘/tmp/RtmpDAngtR/downloaded_packages



我在 Ubuntu 12.04 上使用 R 版本 2.15.2。
首先我认为缺少一些依赖项,但我已经通过突触包管理器安装了 Armadillo (libarmadillo2 v2.4.2),还安装了 g++ (v4.6.3)。我不熟悉 c++,所以我不知道我是否可能需要一些额外的包。但是,安装 Rcpp 可以正常工作。

如果有人可以帮助我,我会很高兴。

最佳答案

install.packagesR CMD INSTALL将(重新)启动 R 并阅读您的 .Rprofile .因此,您应该考虑包装 if (interactive()) { }在您的 .Rprofile 中的代码周围您只想在交互式 session 中运行的文件(例如 libraryrequire 调用)。

否则,您需要使用 --vanilla 启动 R使用前标记 install.packages() ,或使用 R --vanilla CMD INSTALL来自 bash。

关于r - 无法在 R 中编译 RcppArmadillo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13673183/

相关文章:

r - 根据其他时间序列列的超前或滞后创建多个列

r - 如何创建没有NULL/NA的错误向量?

r - 使用 memisc、xtable 等将自定义行添加到 LaTeX 输出的 R 回归结果表中。

c++ - 使用编译器安装库

c++ - 使用 Rcpp 复制 dplyr::group_by 的索引功能

r - 鼠标悬停填充区域时突出显示边框 - Leaflet-R

r - 使用 survminer (ggsurvplot) 将 Kaplan-Meier 图 y 轴更改为失败概率而不是生存概率?

r - 当外部程序通过 R 的 C API 接口(interface)调用 `Rf_allocXXX` 时,谁在管理内存?

r - 如何改进 Rcpp (RcppEigen) 包的 Makevars 文件?

r - 如何在 R 包中使用 'src/' 中的子文件夹?