简体   繁体   English

安装R package时,致命错误:R.h:没有那个文件或目录,如何找到R.h?

[英]when installing a R package, fatal error: R.h: No such file or directory, How to locate R.h?

when installing a R package from github从 github 安装 R package 时

install_github("DataSlingers/ExclusiveLasso")

I get the error messages:我收到错误消息:

* installing *source* package 'ExclusiveLasso' ...
** using staged installation
** libs
g++  -std=gnu++11 -I"/include" -DNDEBUG  -I'D:/R-4.2.2/library/Rcpp/include' -I'D:/R-4.2.2/library/RcppArmadillo/include'   -I"D:/rtools42/x86_64-w64-mingw32.static.posix/include"     -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c ExclusiveLasso.cpp -o ExclusiveLasso.o
In file included from D:/R-4.2.2/library/Rcpp/include/RcppCommon.h:30,
                 from D:/R-4.2.2/library/RcppArmadillo/include/RcppArmadillo/interface/RcppArmadilloForward.h:25,
                 from D:/R-4.2.2/library/RcppArmadillo/include/RcppArmadillo.h:29,
                 from ExclusiveLasso.cpp:23:
D:/R-4.2.2/library/Rcpp/include/Rcpp/r/headers.h:66:10: fatal error: R.h: No such file or directory
   66 | #include <R.h>
      |          ^~~~~
compilation terminated.
make: *** [D:/R-4.2.2/etc/x64/Makeconf:260:ExclusiveLasso.o] 错误 1
ERROR: compilation failed for package 'ExclusiveLasso'
* removing 'D:/R-4.2.2/library/ExclusiveLasso'

I know where my R.h at, and I tried change我知道我的 R.h 在哪里,我尝试更改

#include <R.h> 

into进入

#include <D:/R-4.2.2/include>,

but there's too many files and errors like this但是有太多的文件和这样的错误

It seems that I should tell the g++ where to find D:/R-4.2.2/include, can someone guide me whether I should do that or what should I do.看来我应该告诉 g++ 在哪里可以找到 D:/R-4.2.2/include,有人可以指导我是否应该这样做或者我应该做什么。

I's using: R version 4.2.2 (2022-10-31 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Using vscode我正在使用:R 版本 4.2.2 (2022-10-31 ucrt) 平台:x86_64-w64-mingw32/x64(64 位)使用 vscode

Works fine here on Ubuntu 22.10.在 Ubuntu 22.10 上工作正常。 Note in the log below how it uses -I"/usr/share/R/include" (which is something R itself adds) to point to R's headers.在下面的日志中注意它如何使用-I"/usr/share/R/include" (这是 R 本身添加的内容)指向 R 的标头。 So to me it looks like your R installation is at fault because the src/Makevars.win in that repo is very standard and mostly likely correct.所以对我来说,您的 R 安装似乎有问题,因为该存储库中的src/Makevars.win非常标准并且很可能是正确的。

edd@rob:~$ installGithub.r DataSlingers/ExclusiveLasso  # wrapper around install_github()
Using github PAT from envvar GITHUB_PAT
Downloading GitHub repo DataSlingers/ExclusiveLasso@HEAD

Skipping 1 packages ahead of CRAN: Rcpp
── R CMD build ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✔  checking for file ‘/tmp/remotes2ac86f2646632b/DataSlingers-ExclusiveLasso-ed6b729/DESCRIPTION’ ...
─  preparing ‘ExclusiveLasso’:
✔  checking DESCRIPTION meta-information ...
─  cleaning src
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  building ‘ExclusiveLasso_0.0.tar.gz’
   
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
* installing *source* package ‘ExclusiveLasso’ ...
** using staged installation
** libs
ccache g++  -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG  -I'/usr/local/lib/R/site-library/Rcpp/include' -I'/usr/local/lib/R/site-library/RcppArmadillo/include'    -fpic  -g -O3 -Wall -pipe -pedantic -Wno-ignored-attributes  -c ExclusiveLasso.cpp -o ExclusiveLasso.o
ccache g++  -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG  -I'/usr/local/lib/R/site-library/Rcpp/include' -I'/usr/local/lib/R/site-library/RcppArmadillo/include'    -fpic  -g -O3 -Wall -pipe -pedantic -Wno-ignored-attributes  -c RcppExports.cpp -o RcppExports.o
ccache g++ -std=gnu++11 -Wl,-S -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro -o ExclusiveLasso.so ExclusiveLasso.o RcppExports.o -llapack -lblas -lgfortran -lm -lquadmath -L/usr/lib/R/lib -lR
if test -e "/usr/bin/strip" & test -e "/bin/uname" & [[ `uname` == "Linux" ]] ; then /usr/bin/strip --strip-debug *.o *.so; fi
if test -e "/usr/bin/strip" & test -e "/bin/uname" & [[ `uname` == "Darwin" ]] ; then /usr/bin/strip -S *.o *.so; fi
installing to /usr/local/lib/R/site-library/00LOCK-ExclusiveLasso/00new/ExclusiveLasso/libs
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (ExclusiveLasso)
edd@rob:~$ 

Looking at your installation attempt confirms that because you have查看您的安装尝试确认,因为您有

g++  -std=gnu++11 -I"/include" 

so R does not figure out where its installation is.所以 R 不知道它的安装位置。 Normally you should have通常你应该有

edd@rob:~$ R RHOME
/usr/lib/R
edd@rob:~$ 

but I suspect that too is borked at your end.但我怀疑你这边也很无聊。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM