我想从源代码安装软件包:
设置环境变量:
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
相关:
答案 0 :(得分:2)
您犯了三个错误:
program files
错误,导致64位工具链在32位上使用。BINPREF
目录(bin
和bash
)。强烈建议 将rtools安装在默认位置make
中。这是唯一经过广泛测试的配置。
在这种情况下,只需要将放置C:\Rtools\
放在PATH上即可编译软件包。 R将自动在32位和64位上使用正确的编译器。
如果确实必须在非标准位置安装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)
测试
答案 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")