-
Notifications
You must be signed in to change notification settings - Fork 83
Windows installation
(Instructions provided by Robert O'Boyle)
-
Ensure that latest version of Rstudio, R & Rtools are installed and can be accessed through Rstudio
- If not, uninstall R & Rtools
- Check if Rtools folder exists and if so, delete
-
Install latest version of R
-
Install compatible version of Rtools available on CRAN; during installation
- Unclick 32 bit Rtools
- Click edit system PATH; should have
c:\Rtools\bin;
c:\Rtools\mingw_64\bin;
Note that having
c:\Rtools\mingw_32\bin;
in the path as well as the_64\bin
in the path works for TMB but creates a conflict with ADMB. -
Open R and type
install.packages("TMB")
- This installs the TMB package
-
If there are matrix package inconsistencies, re-install as
install.packages("Matrix")
. -
Check that TMB runs in R.
- Open test files (e.g. linreg files) and ensure that TMB runs
- After running one model, execute
precompile()
; next model run will complete precompilation - When installing and upgrading R & Rtools, make sure all
.o
,.0s
and.dll
files from previous models are removed. They will no longer be compatible with the upgrades
There are sometimes problems getting gdbsource
working on Windows. Using Rtools34
the following steps were required.
Assuming we are running 64 bit R, first verify we are accessing the 64 bit versions of g++
, gdb
and Rterm
by running
> shell("where g++")
c:\Rtools\mingw_32\bin\g++.exe
> shell("where gdb")
C:\Rtools\bin\gdb.exe
c:\Rtools\mingw_32\bin\gdb.exe
> shell("where Rterm")
INFO: Could not find files for the given pattern(s).
There first occurrence is what matters i.e. must be the 64 bit version. In this case we have a problem. We can modify the PATH from within R using this function:
fixwinpath <- function() {
PATH <- Sys.getenv("PATH")
PATH <- paste0(R.home(), "/bin/x64;", PATH)
PATH <- paste0("c:/Rtools/mingw_64/bin;", PATH)
Sys.setenv(PATH=PATH)
}
After running fixwinpath()
you should get the correct 64 bit locations when running the above shell
commands.
To get gdbsource
working you must
- Put
fixwinpath()
at the top of your R script. - Remember to compile with
compile(file, "-O1 -g", DLLFLAGS="")
(WithoutDLLFLAGS=""
you won't get line number info) - If you are using a
precompile()
version of TMB further addlibtmb=FALSE
to thecompile
command.
-
fixwinpath()
works per session hence does not change the globalPATH
. It may be preferable to add it to~/.Rprofile
so that it is invoked for every R session.