Skip to content

Windows Issues

Kyle Baron edited this page Apr 26, 2019 · 40 revisions

Issues with using mrgsolve on Windows platforms

Please share your experience with mrgsolve on Windows platform.
mrgsolve will work on Windows, but we are not every day Windows users.
If you are a Windows user, any feedback you can provide (on the issue tracker) would be greatly appreciated.

Error messages you might encounter

When R cannot find one of the tools to build the shared object, the error message might look like this:

 foo <- mread("pk1",modlib())


---:: stdout ::---------------------------------------------
c:/Rtools/mingw_64/bin/g++
-I"C:/PROGRA~1/R/R-devel/include" -DNDEBUG
-I"c:/Rlibs/mrgsolve/base" -I"c:/Rlibs/mrgsolve/models" -O2
-Wall -mtune=generic -c pk1-mread-source.cpp -o
pk1-mread-source.o

---:: stderr ::---------------------------------------------
sh: c:/Rtools/mingw_64/bin/g++: No such file or directory
make: *** [C:/PROGRA~1/R/R-devel/etc/x64/Makeconf:215: pk1-mread-source.o] Error 127
------------------------------------------------------------
NOTE: 'Error 127' was detected in the above message.
 This possibly indicates that the build toolchain
 could not be found. Please check for proper compiler 
 installation ('Rtools.exe' on Windows).  Also consider
 trying 'pkgbuild::check_build_tools(debug=TRUE)' to
 assist in diagnosing this issue.
------------------------------------------------------------ 
Error: The model build step failed.

Note that we get warnings from make but not even any messages from the compiler.
Look for status 127.

Another message you might see:

 foo <- mread("pk1",modlib())


---:: stdout ::---------------------------------------------


---:: stderr ::---------------------------------------------
Warning messages:
1: In system(paste(cmd, "shlib-clean")) : 'make' not found
2: In system(cmd) : 'make' not found
------------------------------------------------------------
Error: The model build step failed.

You won't see 127 here, but it is clear that the system can't find any of the build tools (e.g. make).

Persistent change to PATH for R

Follow these instructions for setting your system search path in R. It is better if you can set PATH in a system-wide environment variable. Only use the method detailed here if you are unable to make system-wide changes to PATH.

Edit the file in your HOME directory called .Renviron

file.edit("~/.Renviron")

In the $HOME/.Renviron file, add the path to your Rtools installation.

For example

PATH="c:/Rtools/bin;${PATH}"

Be sure to put quotes around the value and use a semi-colon (;) to separate the Rtools part from the other PATH items.

When R starts up, it will read $HOME/.Renviron and set the PATH environment variable (and any other environment variable you want to set here).

Sys.getenv("PATH")

If you installed Rtools in a non-standard location, you will also need to set the BINPREF variable. For example, if you had to install Rtools to c:/myRtools/ then put the following in $HOME/.Renviron:

PATH=c:/myRtools/bin;${PATH}

BINPREF="c:/myRtools/mingw_$(WIN)/bin/"

Note: the BINPREF value must end in a trailing frontslash.

Set a path for your R session

rtools <- "c:/Rtools/bin"

path <- paste0(unique(c(rtools, Sys.getenv("PATH"))), collapse=";")

Sys.setenv(PATH=path)
```

Then check to make sure the path is correct
```r
Sys.getenv("PATH")

For more information:

See ?Startup Also, see: ?readRenviron