I want to install packages from source:
Setting up the environmental variables:
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/")
Installing any package from source results in "cannot find -lR" error:
install.packages("later")
Error message:
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'
As indicated here: https://community.rstudio.com/t/installing-source-package-failure-to-link/14775 it might be the case that for some reason a 32-bit file is linked on my 64-bit machine. But i dont see any Errors in my pathes. (In the past, the install from source worked well).
Sys.info()
sysname release version nodename machine login user effective_user
"Windows" "Server >= 2012 x64" "build 9200" "YY" "x86-64" "XX" "XX" "XX"
Session info:
Version:1.0 StartHTML:0000000107 EndHTML:0000001240 StartFragment:0000000127 EndFragment:0000001222
sessionInfo() R version 3.4.2 (2017-09-28) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows Server >= 2012 x64 (build 9200)
Rstudio 1.1.383
Also posted here: https://community.rstudio.com/t/how-to-avoid-cannot-find-lr-for-r-package-installation-on-windows/49425.
Related:
You are making three mistakes:
program files or any other path with a space. BINPREF wrong, causing the 64-bit toolchain to be used on 32-bit.bin dir (bash and make) should be.It is highly recommended to install rtools in the default location C:\Rtools\. This is the only configuration that is widely tested.
In this case you only need to make put C:\Rtools\bin is on the PATH in order to compile packages. R will automatically use the correct compilers on 32-bit and 64-bit.
If you really must install rtools in a non standard location, you can set BINPREF to a pattern that includes $(WIN) that gets expanded to the correct path for example like so:
Sys.setenv(BINPREF="C:/YourRtoolsPath/mingw_$(WIN)/bin/")
When make invokes the compiler, $(WIN) gets substituted by either 32 or 64 which should then resolve to the correct path of the respective toolchain.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With