无法在R中编译RcppArmadillo

6

我遇到了一个编译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。 起初我认为可能缺少一些依赖项,但是我通过synaptic软件包管理器安装了Armadillo(libarmadillo2 v2.4.2),同时还安装了g++(v4.6.3)。 我不熟悉c ++,所以不知道是否需要其他软件包。 然而,安装Rcpp非常顺利。

如果有人能帮我解决这个问题,我将不胜感激。


1
你是否正在使用 .Rprofile?尝试使用 R --vanilla 启动 R,然后安装。 - GSee
@Gsee 非常感谢您的提示。R--vanilla 工作了。谢谢 :-) - DUWUDA
2个回答

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

否则,在使用install.packages()之前,您需要使用--vanilla标志启动R,或者从bash中使用R --vanilla CMD INSTALL


1

你输入的命令到底是什么?

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

回来了吗?

你知道如何构建一个R包吗?你曾经执行过R CMD INSTALL ....吗? 我碰巧在Ubuntu 12.*上开发这些包,所以我非常确定这个方法可行。

此外,我不确定你阅读了多少文档,但我们从未建议安装libarmadillo以使用RcppArmadillo
该软件包提供了自己的一套Armadillo源代码,用于其自身以及其他使用RcppArmadillo的R包。

而且这个方法非常有效,因为仅CRAN上就有超过20个软件包使用了RcppArmadillo


看起来一个SSH登录消息正在传递给gcc。 - Brandon Bertelsen
我使用了:install.packages("RcppArmadillo") - DUWUDA
我刚才使用了 R CMD INSTALL 'RcppArmadillo_0.3.4.4.tar.gz',但是我收到了相同的错误消息。整个安装过程中,我已经扩展了我的先前报告的代码。 - DUWUDA

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接