Skip to content

Commit df662ed

Browse files
authored
Merge pull request #765 from stan-dev/rtools-toolchain
Update doc to use stock RTools toolchain
2 parents c84dee5 + d75f0a8 commit df662ed

File tree

1 file changed

+23
-84
lines changed

1 file changed

+23
-84
lines changed

src/cmdstan-guide/installation.qmd

Lines changed: 23 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,13 @@ and compiles all necessary C++ libraries.
174174

175175
```
176176
> cd <cmdstan-home>
177-
> make build # on Windows use mingw32-make
177+
> make build
178178
```
179179

180180
If your computer has multiple cores and sufficient ram, the build process
181181
can be parallelized by providing the `-j` option. For example, to build on 4 cores, type:
182182
```
183-
> make -j4 build # on Windows use mingw32-make
183+
> make -j4 build
184184
```
185185

186186
When `make build` is successful, the directory `<cmdstan-home>/bin/`
@@ -202,7 +202,7 @@ See [these instructions](https://helpdeskgeek.com/windows-10/add-windows-path-en
202202
for details on changing the `PATH`.
203203
To permanently make this setting for the current user, you may execute:
204204
```
205-
> mingw32-make install-tbb
205+
> make install-tbb
206206
```
207207
After changing the `PATH` environment variable, you must open an new shell
208208
in order for the new environment variable settings to take effect.
@@ -238,7 +238,7 @@ On Windows:
238238

239239
```
240240
# compile the example
241-
> mingw32-make examples/bernoulli/bernoulli.exe
241+
> make examples/bernoulli/bernoulli.exe
242242
243243
# fit to provided data (results of 10 trials, 2 out of 10 successes)
244244
> ./examples/bernoulli/bernoulli.exe sample data file=examples/bernoulli/bernoulli.data.json
@@ -261,7 +261,7 @@ from the `<cmdstan-home>` directory:
261261

262262
```
263263
> cd <cmdstan-home>
264-
> make clean-all # on Windows use mingw32-make
264+
> make clean-all
265265
> make build
266266
```
267267

@@ -282,19 +282,7 @@ error: PCH file uses an older PCH format that is no longer supported
282282
In this case, clean and rebuild CmdStan, as shown in the previous section.
283283

284284

285-
**Windows: 'mingw32-make' is not recognised**
286-
287-
If the C++ toolchain has been installed but not properly registered,
288-
then the call to `mingw32-make` will result in error message:
289-
```
290-
'mingw32-make' is not recognised as an internal or external command
291-
```
292-
To fix this, ensure you have followed the steps for adding the toolchain to your
293-
`PATH` and installing the additional utilities covered in the
294-
[configuration instructions](#windows)
295-
296-
297-
**Windows: 'g++' or 'cut' is not recognized**
285+
**Windows: 'g++', 'make', or 'cut' is not recognized**
298286

299287
The CmdStan makefile uses a few shell utilities which might not be present in Windows,
300288
resulting in the error message:
@@ -308,7 +296,7 @@ To fix this, ensure you have followed the steps for adding the toolchain to your
308296

309297
**Spaces in paths to CmdStan or model**
310298

311-
Both `make` and `mingw32-make` can fail when dealing with files in folders
299+
`make` can fail when dealing with files in folders
312300
with a space somewhere in their file path. Particularly on Windows, this can
313301
be an issue when CmdStan, or the models you are trying to build, are placed in
314302
the `One Drive` folder.
@@ -317,7 +305,7 @@ Unfortunately, the errors created by this situation are not alwas informative.
317305
Some errors you may see are:
318306

319307
```
320-
mingw32-make: *** INTERNAL: readdir: Invalid argument
308+
make: *** INTERNAL: readdir: Invalid argument
321309
```
322310
```
323311
make: *** [make/program:50: x.hpp] Error 2
@@ -399,93 +387,44 @@ xcode-select --install
399387
#### Windows {#windows}
400388

401389

402-
The Windows toolchain consists of programs `g++`, the C++ compiler, and `mingw32-make`, the GNU Make utility.
390+
The Windows toolchain consists of programs `g++`, the C++ compiler, and `make`, the GNU Make utility.
403391
To check if these are present,
404392
open a command shell [^1]
405393
and type:
406394
```
407395
g++ --version
408-
mingw32-make --version
396+
make --version
409397
```
410398

411-
CmdStan is known compatible with the RTools40, RTools42, and RTools43 toolchains. These require slightly
412-
different steps to configure, so please follow the appropriate steps below. All toolchains will require
399+
CmdStan is known compatible with the RTools43 toolchain. The toolchain will require
413400
updating your `PATH` variable, See [these instructions](https://helpdeskgeek.com/windows-10/add-windows-path-environment-variable/)
414401
for details on changing the `PATH` if you are unfamiliar. The following instructions will assume that the default installation
415402
directory was used, so be sure to update the paths accordingly if you have chosen a different
416403
directory.
417404

418-
##### RTools40
419-
420-
RTools40 provides both a standard `g++-8` toolchain and a `g++-10` Universal C Runtime (UCRT) toolchain.
421-
Note the that newer `g++-10` UCRT toolchain is only available for 64-bit systems, whereas the `g++-8`
422-
toolchain is available for both. Additionally the UCRT is only natively supported on Windows 10 and newer,
423-
older systems will require a [Microsoft update](https://support.microsoft.com/en-us/topic/update-for-universal-c-runtime-in-windows-c0514201-7fe6-95a3-b0a5-287930f3560c)
424-
425-
###### Installation
426-
427-
Download the [installer](https://github.com/r-windows/rtools-installer/releases/download/2022-02-06/rtools40-x86_64.exe)
428-
and complete the prompts to install.
429-
430-
Next, you need to add the location of the toolchain to your `PATH` environment variable so that it
431-
can be called from the command line. Add the following lines to your `PATH`:
432-
```
433-
C:\rtools40\usr\bin
434405

435-
# Add only one of the below
436-
C:\rtools40\mingw32\bin # 32-bit g++-8
437-
C:\rtools40\mingw64\bin # 64-bit g++-8
438-
C:\rtools40\ucrt64\bin # 64-bit g++-10 (UCRT)
439-
```
440-
441-
CmdStan additionally needs the `mingw32-make` utility, which you can install using RTools.
442-
Navigate to the installation directory (e.g., `C:\rtools40`) and launch the `msys2.exe` file.
443-
Execute the appropriate command below to install `mingw32-make` for your selected toolchain:
444-
```
445-
pacman -Sy mingw-w64-i686-make # 32-bit g++-8
446-
pacman -Sy mingw-w64-x86_64-make # 64-bit g++-8
447-
pacman -Sy mingw-w64-ucrt-x86_64-make # 64-bit g++-10 (UCRT)
448-
```
406+
##### RTools43
449407

450-
##### RTools42 & RTools43
408+
All required utilities (e.g., `make`, `g++`) for compiling and running CmdStan models on Windows are
409+
provided by the RTools43 toolchain from the R Project. Installation steps are provided below,
410+
and for more technical details on the toolchain refer to the [R Project documentation](https://cran.r-project.org/bin/windows/Rtools/rtools43/rtools.html).
451411

452-
Both RTools42 & RTools43 provide 64-bit UCRT toolchains, where RTools42 provides g++-10 and
453-
RTools43 provides g++-12. The installation/configuration is identical for both toolchains.
412+
Note that the toolchain is only available for 64-bit systems, and uses the new Universal C Runtime (UCRT).
413+
UCRT is only natively supported on Windows 10 and newer, older systems will require a
414+
[Microsoft update](https://support.microsoft.com/en-us/topic/update-for-universal-c-runtime-in-windows-c0514201-7fe6-95a3-b0a5-287930f3560c).
454415

455416
###### Installation
456417

457-
Download the installer for your preferred toolchain and complete the prompts for installation:
418+
Download the installer and complete the prompts for installation:
458419

459-
- [RTools42](https://cran.r-project.org/bin/windows/Rtools/rtools42/files/rtools42-5355-5357.exe)
460420
- [RTools43](https://cran.r-project.org/bin/windows/Rtools/rtools43/files/rtools43-5958-5975.exe)
461421

462422
Next, you need to add the toolchain directory to your `PATH` variable. Add the appropriate lines
463423
from below:
464424
```
465-
# RTools42
466-
C:\rtools42\usr\bin
467-
C:\rtools42\ucrt64\bin
468-
469-
# RTools43
470425
C:\rtools43\usr\bin
471-
C:\rtools43\ucrt64\bin
472-
```
473-
474-
Next, you need to install the `mingw32-make` utility and some additional compiler dependencies.
475-
Navigate to the installation directory of the toolchain and launch the `msys2.exe` file.
476-
Execute the below commands to install the needed dependencies:
426+
C:\rtools43\x86_64-w64-mingw32.static.posix\bin
477427
```
478-
pacman -Sy mingw-w64-ucrt-x86_64-make mingw-w64-ucrt-x86_64-gcc
479-
```
480-
481-
[^1]:
482-
To open a Windows command shell, first open the __Start Menu__,
483-
(usually in the lower left of the screen), select option __All Programs__,
484-
then option __Accessories__, then program __Command Prompt__.
485-
Alternatively, enter `[Windows+r]` (both keys together on the
486-
keyboard), and enter `cmd` into the text field that pops up in the Run window,
487-
then press `[Return]` on the keyboard to run.
488-
489428

490429
## Using GNU Make {#gnu-make}
491430

@@ -533,7 +472,7 @@ into a binary executable.
533472
For example, to compile the Stan program `my_program.stan` in directory `../my_dir/`,
534473
the make target is `../my_dir/my_program` or ` ../my_dir/my_program.exe` (on Windows).
535474

536-
To call Make, you invoke the utility name, either `make` or `mingw32-make`, followed by, in order:
475+
To call Make, you invoke the utility name, `make`, followed by, in order:
537476

538477
- zero or more [Make program options](https://www.gnu.org/software/make/manual/html_node/Options-Summary.html), then specify any Make variables as a series of
539478

@@ -552,7 +491,7 @@ Make targets can be preceded by any number of Makefile variable name=value pairs
552491
For example, to compile `../my_dir/my_program.stan` for an OpenCL (GPU) machine,
553492
set the makefile variable `STAN_OPENCL` to `TRUE`:
554493
```
555-
> make STAN_OPENCL=TRUE ../my_dir/my_program # on Windows use mingw32-make
494+
> make STAN_OPENCL=TRUE ../my_dir/my_program
556495
```
557496
Makefile variables can also be set by creating a file named `local` in the
558497
CmdStan `make` subdirectory which contains a list of `<VARIABLE>=<VALUE>` pairs,
@@ -567,7 +506,7 @@ __Make Targets__
567506

568507
When invoked without any arguments at all, Make prints a help message:
569508
```
570-
> make # on Windows use mingw32-make
509+
> make
571510
--------------------------------------------------------------------------------
572511
CmdStan v2.33.1 help
573512

0 commit comments

Comments
 (0)