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:

* <https://support.bioconductor.org/p/11509/> (But my sessionInfo does not Point to any Linux Version).