Skip to content

Instantly share code, notes, and snippets.

@javierluraschi
Last active March 28, 2019 17:18
Show Gist options
  • Save javierluraschi/4c974cf4468ff01c88723d27e7fc091a to your computer and use it in GitHub Desktop.
Save javierluraschi/4c974cf4468ff01c88723d27e7fc091a to your computer and use it in GitHub Desktop.
Build R from Windows
##A Partial Guide for Building R in Windows
**Summary:** Start with this guide [R Admin - The Windows Toolset](https://cran.r-project.org/doc/manuals/R-admin.html#The-Windows-toolset) and **carefully follow each step**. Use the information bellow as an overview not a replacement to the mentioned guide.
### Overview ###
Download RTools, install for full develoment
Install R sources from SVN
Create your own copy of `MkRules`:
```
cd R_HOME/src/gnuwin32
cp MkRules.dist MkRules.local
```
RSync the tools:
```
make rsync-recommended
```
Set appropiate environment variables `R_HOME`:
```
setx R_HOME "c:\Users\javierp-win-vm\RStudio\[RDEVEL-HOME]"
```
Mofify `MkRules` appropiately,
```
BINPREF = c:/Rtools/mingw_32/bin/
```
Download https://www.stats.ox.ac.uk/pub/Rtools/goodies/multilib/local323.zip
```
unzip local323.zip -d <R_HOME>/extsoft
```
Sync External Software:
```
make rsync-extsoft
```
Make sure a `TMPDIR` is set! Otherwise the build will break since the default `TMPDIR` is not good in windows.
"The tcltk package needs Tcl/Tk" build breaks unless tcl.tk get installed.
Howeve,r in my case, I was not able to build `Tcl/Tk`, kept hitting this error:
```
c:/RBuildTools/3.3/mingw_32/bin/gcc -I"../../../../include" -DNDEBUG -I "../../../../Tcl"/include -DWin32 -I../../../../src/include -DHAVE_CONFIG_H -I"C:/Users/javierp-win-vm/RStudio/[RDEVEL-HOME]/extsoft/include" -O3 -Wall -std=gnu99 -mtune=core2 -c init.c -o init.o
In file included from init.c:22:0:
tcltk.h:25:17: fatal error: tcl.h: No such file or directory
```
After much fiddling, I decided to turn off this build change in `[RDEVEL-HOME]\src\library\tcltk`:
```
BUILD_TCLTK = no
```
Make from `<R_HOME>\src\gnuwin32`
```
make all recommended vignettes
```
That said, even without `Tcl/Tk`, I was able to `Rprintf` to debug particular issues in R core. `r-devel` mailing list mentioned `Rprintf` statements are a descent debugging technique in Windows. With a bit more work, one might be able to get `gdb` working in Windows; however, there is no known front end that integrates nicely with `gdb` and `r-core` in Windows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment