What does this error message mean, how do I fix it

This error runs whenever I try to fit a model:

Error in inDL(x, as.logical(local), as.logical(now), …) :
unable to load shared object ‘C:/Users/NICK~1.MIL/AppData/Local/Temp/RtmpKgEhva/file3e2838ea143c.dll’:
LoadLibrary failure: A dynamic link library (DLL) initialization routine failed.
In addition: Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
‘C:/rtools40/usr/mingw_/bin/g++’ not found
Error in sink(type = “output”) : invalid connection
Any help?

Can you try reinstalling rstan and stanheaders from source and trying again?