Compiler Support fo C++ 14 Features on Windows


I am currently in the process of developing a package to support common operations on sparse matrices (github const-ae/sparseMatrixStats).

For reasons, my C++ code is written in a way so that it requires features from the C++ 14 standard.

I am using GitHub actions as a continuous integration tool and my tests work well on Mac and Linux:
The checks alls succeed on winbuilder.

I do, however, have the problem that I cannot get the package to compile on Windows. I have already tried different combinations of requiring C++14 via the DESCRIPTION file and via the file. But so far no luck.

I also found this blogpost by Dirk Eddelbuettel discussing a similar issue, but also couldn't apply it to my problem.
A second thing I tried, was to manually create the HOME/.R/.Makevars file, but that also failed: github const-ae/sparseMatrixStats/runs/519689485?check_suite_focus=true

I wanted to ask, if there is any way to get support for C++14 on Windows in GitHub actions and what would be the best way to go about it?

Best, Constantin

PS: Sorry for the botched links, but I am only allowed to include two links for some reasons?!

Rtools 35 uses gcc 4.9.3, which does not have support for all of C++14. This toolchain is what is used currently by CRAN to build windows binaries, so currently your package cannot depend on C++14 and build on windows.

For the yet unreleased R 4.0 there is currently a experimental Rtools40 toolchain based on gcc 8, that would support C++14.

You can control what version of RTools is installed with the rtools-version parameter to the setup-r action, however if you do decide to experiment with RTools 40 you will have to solve any resultant issues yourself.

Personally I would look very hard at if you actually need C++14 and reduce the dependency to C++11 if you can, you will have far fewer headaches.

1 Like

Thanks, for your prompt and insightful reply.

I set the rtools-version to 40 but that only lead to actions/setup-r crashing:

I guess the problem is here where it is trying to download the Rtools executable. But the link for Rtools40 differs:

For now, I will give up getting CI to run on Windows and just be happy that winbuilder is successful. In the medium term, I will consider removing the C++14 features, but as I am targeting the next BioConductor release, depending on R 4.0 should be fine :slight_smile:


I tried enabling rtools version 40 in GitHub - lcolladotor/actions at support_win_rtools_40 by editing the construction of the URL in r-lib/actions/setup-r. I thought it could be a simple fix & a small PR.

But well, my tests failed at with no apparent error message (just like in

Run lcolladotor/actions/setup-r@support_win_rtools_40
    r-version: devel
    rtools-version: 40
    Ncpus: 1
    crayon.enabled: TRUE
    remove-openmp-macos: true
choco install qpdf --no-progress
d:\a\_temp\R-devel-win.exe /VERYSILENT /SUPPRESSMSGBOXES /DIR=C:\R
Chocolatey v0.10.15
Installing the following packages:
By installing you accept licenses for the packages.

qpdf v10.0.1 [Approved]
qpdf package files install completed. Performing other installation steps.
Extracting C:\ProgramData\chocolatey\lib\qpdf\tools\ to C:\ProgramData\chocolatey\lib\qpdf\tools...
 ShimGen has successfully created a shim for fix-qdf.exe
 ShimGen has successfully created a shim for qpdf.exe
 ShimGen has successfully created a shim for zlib-flate.exe
 The install of qpdf was successful.
  Software installed to 'C:\ProgramData\chocolatey\lib\qpdf\tools'

I tried a few more tests in GitHub - lcolladotor/actions at support_win_rtools_40_edit_repo_config with Complete the trifecta of tests · LieberInstitute/recount3@b28956f · GitHub being the latest one producing this report

I do see one error elsewhere that seems unrelated to me:

Exit code 1 returned from process: file name 'c:\runners\2.169.0\bin\Runner.PluginHost.exe', arguments 'action "GitHub.Runner.Plugins.Artifact.PublishArtifact, Runner.Plugins"'.

Anyway, you might be interested in this @const-ae. Though most likely we'll have to rely on Jim's magic :wink:


Hi Leonardo,

thank you for chiming in and giving it a try to fix the problem :slight_smile:

Funny enough, I discovered yesterday that Windows with R-devel and Rtools 35 actually is now able to build C++14 code.

  • Windows R-devel with Rtools 35 is sucessful

  • Windows R-release with Rtools 35 fails noting that CXX14 is not defined

Best, Constantin

Hi Constantin,

Ohh, interesting!

r-lib, R-devel, Rtools 35

My first test with R-devel using r-lib/actions/setup-r and the default Rtools 35 did install R but failed later with multiple instances of the error:

sh: c:/rtools40/mingw32/bin/gcc: No such file or directory

GHA log and GHA workflow yml. That's when I read this thread and started my and GitHub - lcolladotor/actions at support_win_rtools_40_edit_repo_config tests.

Now in the day with more light I see that it was calling a path with rtools40 already :sweat_smile:

2020-04-19T04:04:30.3668057Z     Run a test with windows (r-devel) just to see how that goes
2020-04-19T04:04:30.3928899Z ##[group]Run r-lib/actions/setup-r@master
2020-04-19T04:04:30.3929052Z with:
2020-04-19T04:04:30.3929194Z   r-version: devel
2020-04-19T04:04:30.3929260Z   rtools-version: 35
2020-04-19T04:04:30.3929338Z   Ncpus: 1
2020-04-19T04:04:30.3929418Z   crayon.enabled: TRUE
2020-04-19T04:04:30.3929499Z   remove-openmp-macos: true
2020-04-19T04:04:30.3929564Z env:
2020-04-19T04:04:30.3929645Z   R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
2020-04-19T04:04:30.3929733Z   RSPM: 
2020-04-19T04:04:30.3929810Z   BIOCVERSIONNUM: 3.11
2020-04-19T04:04:30.3929873Z ##[endgroup]
2020-04-19T04:04:30.7892723Z [command]choco install qpdf --no-progress
2020-04-19T04:04:31.3248441Z [command]d:\a\_temp\Rtools35.exe /VERYSILENT /SUPPRESSMSGBOXES
2020-04-19T04:04:32.9170557Z Chocolatey v0.10.15
2020-04-19T04:04:33.6341189Z [command]d:\a\_temp\R-devel-win.exe /VERYSILENT /SUPPRESSMSGBOXES /DIR=C:\R

From the full logs I see that it was installing Rtools 35 though.

New test

I just submitted a new test using R-devel with Rtools 35, like you did here.

Though now I'm running into a new unrelated error:

Error in utils::download.file(url, path, method = download_method(), quiet = quiet,  : 
  cannot open URL ',knitr,rmarkdown,BiocStyle,knitcitations,sessioninfo,testthat,RefManageR,covr,SummarizedExperiment,BiocFileCache,AnnotationHub'
Calls: cat ... get_cran_deps -> download_json -> download -> <Anonymous>
In addition: Warning message:
In utils::download.file(url, path, method = download_method(), quiet = quiet,  :
  cannot open URL ',knitr,rmarkdown,BiocStyle,knitcitations,sessioninfo,testthat,RefManageR,covr,SummarizedExperiment,BiocFileCache,AnnotationHub': HTTP status was '404 Not Found'
Execution halted
##[error]Process completed with exit code 1.

Jeroen Ooms

I see that my fork at GitHub - lcolladotor/actions: GitHub Actions for the R community is 1 commit behind master... and that commit is by Jeroen Ooms and Jim Hester, where they add the code for Rtools 40 for Windows Use rtools40 for R >= 4.0 · r-lib/actions@4d14c61 · GitHub hehe.


Hi again @const-ae,

I see that in your workflow file you are specifying the R version with a string (devel/release) but you also specified the rtools version. If you hadn't, in the latest version (merged by Jim about 1-2 hours ago), I think that you would have ran into an issue. See my question at Jeroen's PR.