2013-04-03 93 views
0

我無法安裝多個R包,因爲它們總是在第一個include語句中失敗。這是我得到RCPP錯誤:如何安裝使用頭文件(RJSONIO,Rcpp)的R軟件包?

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 

我sessionInfo()

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 

回答

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版本)

[email protected]:~/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什麼的...

+1

我覺得我的〜/ .R/Makevars搞砸了。我在哪裏可以找到原始版本的Makevars? – nachocab

+0

只需將其刪除即可嘗試,然後將其逐行放回。 –

+0

這樣做。謝謝! – nachocab