如何避免在Windows上安装R软件包时出现“找不到-lR”

时间:2020-01-13 16:10:48

标签: r windows

我想从源代码安装软件包:

设置环境变量:

applyTo()

从源代码安装任何软件包都会导致“找不到-lR”错误:

Base

错误消息:

Sys.setenv(BINPREF = "C:/PROGRA~1/R/Rtools/mingw_64/bin/")
Sys.setenv(BINPREF64 = "C:/PROGRA~1/R/Rtools/mingw_64/bin/")
Sys.setenv(PATH = "C:/PROGRA~1/R/R-3.4.2/bin/x64/;C:/PROGRA~1/R/Rtools/bin/;C:/PROGRA~1/R/Rtools/mingw_64/bin/")

如此处所示:https://community.rstudio.com/t/installing-source-package-failure-to-link/14775可能由于某种原因在我的64位计算机上链接了32位文件。但是我在我的路径中看不到任何错误。 (过去,从源代码进行的安装效果很好)。

install.packages("later")

会话信息:

C:/PROGRA~1/R/Rtools/mingw_64/bin/g++ -shared -s -static-libgcc -o
later.dll tmp.def RcppExports.o callback_registry.o debug.o init.o
later.o later_posix.o later_win32.o timer_posix.o timestamp_unix.o
timestamp_win32.o tinycthread.o
-Ld:/Compiler/gcc-4.9.3/local330/lib/i386 -Ld:/Compiler/gcc-4.9.3/local330/lib -LC:/PROGRA~1/R/R-34~1.2/bin/i386 -lR C:/PROGRA~1/R/Rtools/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe:
skipping incompatible C:/PROGRA~1/R/R-34~1.2/bin/i386/R.dll when searching for -lR
C:/PROGRA~1/R/Rtools/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe:
skipping incompatible C:/PROGRA~1/R/R-34~1.2/bin/i386/R.dll when searching for -lR
C:/PROGRA~1/R/Rtools/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe:
cannot find -lR collect2.exe: error: ld returned 1 exit status no DLL
was created
ERROR: compilation failed for package 'later'

Rstudio 1.1.383

也张贴在这里:https://community.rstudio.com/t/how-to-avoid-cannot-find-lr-for-r-package-installation-on-windows/49425

相关:

3 个答案:

答案 0 :(得分:2)

您犯了三个错误:

  1. 请勿在{{1​​}}或任何其他带空格的路径下安装rtools。
  2. 您使用的program files错误,导致64位工具链在32位上使用。
  3. mingw gcc目录应该在PATH上。仅BINPREF目录(binbash)。

推荐的设置:

强烈建议 将rtools安装在默认位置make中。这是唯一经过广泛测试的配置。

在这种情况下,只需要将放置C:\Rtools\放在PATH上即可编译软件包。 R将自动在32位和64位上使用正确的编译器。

使用非默认Rtools位置:

如果确实必须在非标准位置安装rtools,则可以将C:\Rtools\bin设置为包含BINPREF的模式,该模式会扩展为正确的路径,例如:

$(WIN)

Sys.setenv(BINPREF="C:/YourRtoolsPath/mingw_$(WIN)/bin/") 调用编译器时,make$(WIN)32替代,然后应解析为相应工具链的正确路径。

答案 1 :(得分:0)

使用R安装rtools35版本3.6.2 然后,当您安装Rtools35时,在将rtools添加到系统路径中选中是 然后用later::later(function() {print("Got here!")}, 5)测试 later package test

答案 2 :(得分:-1)

您在跳过R.dll时遇到问题,无法链接。

尝试使用其他版本的构建工具链,例如Microsoft VC ++((link.exe))或mingw32

您是否可以编译其他软件包

请尝试此测试以查看是否存在错误

ccode <- 'extern "C" {void test() {double x=2.1; x = x+1;}}\n'
cat(file="R_Cpp_Test.cpp", ccode)
system("R CMD SHLIB R_Cpp_Test.cpp")