0

我无法安装多个 R 包,因为它们总是在第一个包含语句中失败。这是我为 Rcpp 得到的错误:

install.packages("/Users/nacho/Downloads/Rcpp_0.10.3.tar.gz", repos=NULL, type="source")
Installing package(s) into ‘/Users/nacho/Library/R/2.15/library’
(as ‘lib’ is unspecified)
* installing *source* package ‘Rcpp’ ...
** package ‘Rcpp’ successfully unpacked and MD5 sums checked
** libs
c++ -I/usr/local/Cellar/r/2.15.2/R.framework/Resources/include -DNDEBUG -fopenmp -I/usr/local/include   -fopenmp -fPIC  -g -O2  -c Date.cpp -o Date.o
clang: warning: argument unused during compilation: '-fopenmp'
clang: warning: argument unused during compilation: '-fopenmp'
Date.cpp:29:10: fatal error: 'Rcpp/Datetime.h' file not found
#include <Rcpp/Datetime.h>
         ^
1 error generated.
make: *** [Date.o] Error 1
ERROR: compilation failed for package ‘Rcpp’
* removing ‘/Users/nacho/Library/R/2.15/library/Rcpp’
Warning message:
In install.packages("/Users/nacho/Downloads/Rcpp_0.10.3.tar.gz",  :
  installation of package ‘/Users/nacho/Downloads/Rcpp_0.10.3.tar.gz’ had non-zero exit status

对于 RJSONIO,我得到了同样的错误

install.packages("/Users/nacho/Downloads/RJSONIO_1.0-3.tar.gz", repos=NULL, type="source")
Installing package(s) into ‘/Users/nacho/Library/R/2.15/library’
(as ‘lib’ is unspecified)
* installing *source* package ‘RJSONIO’ ...
** package ‘RJSONIO’ successfully unpacked and MD5 sums checked
Trying to find libjson.h header file
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
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
USE_LOCAL = ""
Minor Version: 6
Using local libjson code. Copying files from src/libjson/Source
/private/var/folders/tl/_8_djcq15pl01ht8z6hy9tww0000gn/T/RtmpMKCuPF/R.INSTALL116ed562675dc/RJSONIO
JSONAllocator.cpp
JSONChildren.cpp
JSONDebug.cpp
JSONIterators.cpp
JSONMemory.cpp
JSONNode.cpp
JSONNode_Mutex.cpp
JSONPreparse.cpp
JSONStream.cpp
JSONValidator.cpp
JSONWorker.cpp
JSONWriter.cpp
internalJSONNode.cpp
libjson.cpp
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating cleanup
** libs
cc -I/usr/local/Cellar/r/2.15.2/R.framework/Resources/include -DNDEBUG -fopenmp -I/usr/local/include   -fopenmp -fPIC  -g -O2  -c ConvertUTF.c -o ConvertUTF.o
clang: warning: argument unused during compilation: '-fopenmp'
clang: warning: argument unused during compilation: '-fopenmp'
c++ -I/usr/local/Cellar/r/2.15.2/R.framework/Resources/include -DNDEBUG -fopenmp -I/usr/local/include   -fopenmp -fPIC  -g -O2  -c JSONAllocator.cpp -o JSONAllocator.o
clang: warning: argument unused during compilation: '-fopenmp'
clang: warning: argument unused during compilation: '-fopenmp'
JSONAllocator.cpp:1:10: fatal error: 'JSONAllocator.h' file not found
#include "JSONAllocator.h"
       ^
1 error generated.
make: *** [JSONAllocator.o] Error 1
ERROR: compilation failed for package ‘RJSONIO’
* removing ‘/Users/nacho/Library/R/2.15/library/RJSONIO’
Warning message:
In install.packages("/Users/nacho/Downloads/RJSONIO_1.0-3.tar.gz",  :
installation of package ‘/Users/nacho/Downloads/RJSONIO_1.0-3.tar.gz’ had non-zero exit status  

我的会话信息()

R version 2.15.2 (2012-10-26)
Platform: x86_64-apple-darwin11.4.2 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] graphics  grDevices utils     datasets  stats     grid      methods   base

other attached packages:
[1] clickme_0.0.3   ggplot2_0.9.3.1 testthat_0.7.1  devtools_1.1

loaded via a namespace (and not attached):
 [1] colorspace_1.2-1   dichromat_2.0-0    digest_0.6.3       evaluate_0.4.3     formatR_0.7        gtable_0.1.2
 [7] httr_0.2           knitr_1.1          labeling_0.1       MASS_7.3-23        memoise_0.1        munsell_0.4
[13] parallel_2.15.2    plyr_1.8           proto_0.3-10       RColorBrewer_1.0-5 RCurl_1.95-4.1     reshape2_1.2.2
[19] scales_0.2.3       stringr_0.6.2      tools_2.15.2       whisker_0.1        yaml_2.1.7
4

1 回答 1

2

当你尝试时会发生什么

 R CMD INSTALL Rcpp_0.10.3.tar.gz

反而?从您显示的日志中:

c++ -I/usr/local/Cellar/r/2.15.2/R.framework/Resources/include -DNDEBUG \
   -fopenmp -I/usr/local/include   -fopenmp -fPIC  -g -O2  -c Date.cpp -o Date.o

很明显你遗漏了一些东西。在我的 Linux 机器上(你可以忽略我使用当前 SVN 版本的事实)

edd@max:~/svn/rcpp/pkg$ R CMD INSTALL Rcpp_0.10.3.1.tar.gz 
* installing to library ‘/usr/local/lib/R/site-library’
* installing *source* package ‘Rcpp’ ...
** libs
ccache g++-4.7 -I/usr/share/R/include -DNDEBUG -I../inst/include/ \
   -fpic -g0 -O3 -Wall -pipe -Wno-variadic-macros -pedantic -c Date.cpp -o Date.o

注意-I../inst/include这里?也许你覆盖CXXFLAGS了或什么...

于 2013-04-03T11:17:12.527 回答