我无法在Windows上从源代码编译软件包。这个问题似乎与在编译步骤中解决路径有关。按照来自Rtools4安装页面的示例,我得到一个错误如下:
> install.packages("jsonlite", type = "source")
trying URL 'https://cran.rstudio.com/src/contrib/jsonlite_1.7.3.tar.gz'
Content type 'application/x-gzip' length 1051573 bytes (1.0 MB)
downloaded 1.0 MB
* installing *source* package 'jsonlite' ...
** package 'jsonlite' successfully unpacked and MD5 sums checked
** using staged installation
** libs
*** arch - i386
C:\Rtools\mingw_64gcc -I"C:/Users/<username>/DOCUME~1/R/R-41~1.2/include" -DNDEBUG -Iyajl/api -D__USE_MINGW_ANSI_STDIO -O2 -Wall -std=gnu99 -mfpmath=sse -msse2 -mstackrealign -c base64.c -o base64.o
sh: line 1: C:Rtoolsmingw_64gcc: command not found
make: *** [C:/Users/<username>/DOCUME~1/R/R-41~1.2/etc/i386/Makeconf:238: base64.o] Error 127
ERROR: compilation failed for package 'jsonlite'
* removing 'C:/Users/<username>/Documents/R/R-4.1.2/library/jsonlite'
* restoring previous 'C:/Users/<username>/Documents/R/R-4.1.2/library/jsonlite'
Warning in install.packages :
installation of package ‘jsonlite’ had non-zero exit status我发现非常奇怪的是,在以sh:开头的行中没有文件分隔符。应该有路径分隔符,但对gcc的调用似乎缺少它们。有什么地方可以纠正这条路吗?我还会注意到,我已经证实了gcc的存在,但这是在C:\Rtools\mingw_64\bin,而不是C:\Rtools\mingw_64,因为这句话似乎意味着它在寻找它。我可以确认包含gcc .exe文件的文件夹在我的路径上。任何关于如何确保gcc的正确道路的建议,我们都将不胜感激。
这是在一个新安装的R4.1.2与RTools4。
作为参考,
> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] devtools_2.4.3 usethis_2.1.5
loaded via a namespace (and not attached):
[1] magrittr_2.0.2 pkgload_1.2.4 R6_2.5.1 rlang_1.0.1 fastmap_1.1.0 tools_4.1.2
[7] pkgbuild_1.3.1 sessioninfo_1.2.2 cli_3.1.1 withr_2.4.3 ellipsis_0.3.2 remotes_2.4.2
[13] rprojroot_2.0.2 lifecycle_1.0.1 crayon_1.4.2 brio_1.1.3 processx_3.5.2 purrr_0.3.4
[19] callr_3.7.0 fs_1.5.2 ps_1.6.0 testthat_3.1.2 memoise_2.0.1 glue_1.6.1
[25] cachem_1.0.6 compiler_4.1.2 desc_1.4.0 prettyunits_1.1.1发布于 2022-02-11 16:22:06
我不知道这个问题的根本原因是什么,但是我能够通过编辑C:\Users\<username>\Documents\R\R-4.1.2\etc\i386和C:\Users\<username>\Documents\R\R-4.1.2\etc\x64的Makeconf文件来解决这个问题。我在那里做的两个改变
RTOOLS40_HOME ?= c:/rtools和
BINPREF = "$(RTOOLS40_ROOT)/mingw32/bin/"如果有一个解释,为什么这解决了问题,我会感谢听到它!
https://stackoverflow.com/questions/71025101
复制相似问题