Problem running rstan with R 4.0.2

I am encountering the same warning as the OP in this thread (namely “‘C:/rtools40/usr/mingw_/bin/g++’ not found”). Like the OP I don’t have a directory called C:/rtools40/usr/mingw_/bin (although I do have C:\rtools40\mingw64\bin). However, I notice that RStan Getting Started · stan-dev/rstan Wiki · GitHub says:

On Windows you may get a warning about g++ not being found but this appears to be harmless.

I assume this refers to the warning we are getting. Is that right?

In my case it does seem to be harmless, although I have not kept timings, and therefore I don’t know whether it has affected compilation times, or sampling times.

Update: The combined thread on these kinds of issues has the definitive reply (I think) to this warning: Rstan on Windows - #123 by bgoodri

It is harmless unless you have #include statements in your Stan program.

1 Like

I ran this code and I get these errors:

> file <- file.path(cmdstan_path(), "examples", "bernoulli", "bernoulli.stan")
> mod <- cmdstan_model(file)
Compiling Stan program...
Informationÿ: impossible de trouver des fichiers pour le(s) modŠle(s) sp‚cifi‚(s).
Informationÿ: impossible de trouver des fichiers pour le(s) modŠle(s) sp‚cifi‚(s).
ar: création de stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_nvecserial.a
ar: création de stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_cvodes.a
ar: création de stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_idas.a
ar: création de stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_kinsol.a
C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb_2019_U8/build/Makefile.tbb:28: CONFIG: cfg=release arch=intel64 compiler=gcc target=windows runtime=mingw8.3.0
task.o: duplicate section `.rdata$_ZTIN3tbb4taskE[_ZTIN3tbb4taskE]' has different size
arena.o: duplicate section `.rdata$_ZTIN3tbb4taskE[_ZTIN3tbb4taskE]' has different size
scheduler.o: duplicate section `.rdata$_ZTIN3tbb4taskE[_ZTIN3tbb4taskE]' has different size
C:/Program Files/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find C:/Program: No such file or directory
C:/Program Files/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find Files/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/lib/../lib/default-manifest.o: No such file or directory
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe: *** [make/program:62: C:/Users/Antoine/AppData/Local/Temp/RtmpstbwaD/model-21a02d866116.exe] Error 1
Erreur : An error occured during compilation! See the message above for more information.

If it says “cannot find C:/Program: No such file in directory”, isn’t that an indication that the space in “Program Files” causes problems?

Concerning the “g++” warning message when running stan(), I confirm that it does not seem to prevent anything, I was able to run multiple (simple) models without issues.

Cheers

Can you run the following:

writeLines('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', con = "~/.Renviron")

and restart R or Rstudio and then run:

rebuild_cmdstan(cores = 4)
1 Like

It’s an awful lot of lines that I can’t all paste here, so I’m only pasting the first part and chunks with red messages:

library(cmdstanr)
This is cmdstanr version 0.1.1
- Online documentation and vignettes at mc-stan.org/cmdstanr
- CmdStan path set to: C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0
- Use set_cmdstan_path() to change the path
> rebuild_cmdstan(cores = 4)
Informationÿ: impossible de trouver des fichiers pour le(s) modŠle(s) sp‚cifi‚(s).
rm -f -r test
rm -f 
rm -f 
rm -f 
rm -f 
  removing dependency files
rm -f src/cmdstan/main.d   stan//src/stan/model/model_header.d
rm -f   
rm -f   
  cleaning sundials targets
rm -f stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_cvodes.a stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_idas.a stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_kinsol.a stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_nvecserial.a stan/lib/stan_math/lib/sundials_5.2.0/src/cvodes/cvodea.o stan/lib/stan_math/lib/sundials_5.2.0/src/cvodes/cvodea_io.o stan/lib/stan_math/lib/sundials_5.2.0/src/cvodes/cvodes.o stan/lib/stan_math/lib/sundials_5.2.0/src/cvodes/cvodes_bandpre.o stan/lib/stan_math/lib/sundials_5.2.0/src/cvodes/cvodes_bbdpre.o stan/lib/stan_math/lib/sundials_5.2.0/src/cvodes/cvodes_diag.o stan/lib/stan_math/lib/sundials_5.2.0/src/cvodes/cvodes_direct.o stan/lib/stan_math/lib/sundials_5.2.0/src/cvodes/cvodes_io.o stan/lib/stan_math/lib/sundials_5.2.0/src/cvodes/cvodes_ls.o stan/lib/stan_math/lib/sundials_5.2.0/src/cvodes/cvodes_nls.o stan/lib/stan_math/lib/sundials_5.2.0/src/cvodes/cvodes_nls_sim.o stan/lib/stan_math/lib/sundials_5.2.0/src/cvodes/cvodes_nls_stg.o stan/lib/stan_math/lib/sundials_5.2.0/src/cvodes/cvodes_nls_stg1.o stan/lib/stan_math/lib/sundials_5.2.0/src/cvodes/cvodes_spils.o stan/lib/stan_math/lib/sundials_5.2.0/src/idas/idaa.o stan/lib/stan_math/lib/sundials_5.2.0/src/idas/idaa_io.o stan/lib/stan_math/lib/sundials_5.2.0/src/idas/idas.o stan/lib/stan_math/lib/sundials_5.2.0/src/idas/idas_bbdpre.o stan/lib/stan_math/lib/sundials_5.2.0/src/idas/idas_direct.o stan/lib/stan_math/lib/sundials_5.2.0/src/idas/idas_ic.o stan/lib/stan_math/lib/sundials_5.2.0/src/idas/idas_io.o stan/lib/stan_math/lib/sundials_5.2.0/src/idas/idas_ls.o stan/lib/stan_math/lib/sundials_5.2.0/src/idas/idas_nls.o stan/lib/stan_math/lib/sundials_5.2.0/src/idas/idas_nls_sim.o stan/lib/stan_math/lib/sundials_5.2.0/src/idas/idas_nls_stg.o stan/lib/stan_math/lib/sundials_5.2.0/src/idas/idas_spils.o stan/lib/stan_math/lib/sundials_5.2.0/src/kinsol/kinsol.o stan/lib/stan_math/lib/sundials_5.2.0/src/kinsol/kinsol_bbdpre.o stan/lib/stan_math/lib/sundials_5.2.0/src/kinsol/kinsol_direct.o stan/lib/stan_math/lib/sundials_5.2.0/src/kinsol/kinsol_io.o stan/lib/stan_math/lib/sundials_5.2.0/src/kinsol/kinsol_ls.o stan/lib/stan_math/lib/sundials_5.2.0/src/kinsol/kinsol_spils.o stan/lib/stan_math/lib/sundials_5.2.0/src/nvector/serial/nvector_serial.o stan/lib/stan_math/lib/sundials_5.2.0/src/sundials/sundials_band.o stan/lib/stan_math/lib/sundials_5.2.0/src/sundials/sundials_dense.o stan/lib/stan_math/lib/sundials_5.2.0/src/sundials/sundials_direct.o stan/lib/stan_math/lib/sundials_5.2.0/src/sundials/sundials_futils.o stan/lib/stan_math/lib/sundials_5.2.0/src/sundials/sundials_iterative.o stan/lib/stan_math/lib/sundials_5.2.0/src/sundials/sundials_linearsolver.o stan/lib/stan_math/lib/sundials_5.2.0/src/sundials/sundials_math.o stan/lib/stan_math/lib/sundials_5.2.0/src/sundials/sundials_matrix.o stan/lib/stan_math/lib/sundials_5.2.0/src/sundials/sundials_nonlinearsolver.o stan/lib/stan_math/lib/sundials_5.2.0/src/sundials/sundials_nvector.o stan/lib/stan_math/lib/sundials_5.2.0/src/sundials/sundials_nvector_senswrapper.o stan/lib/stan_math/lib/sundials_5.2.0/src/sundials/sundials_version.o stan/lib/stan_math/lib/sundials_5.2.0/src/sunlinsol/band/sunlinsol_band.o stan/lib/stan_math/lib/sundials_5.2.0/src/sunlinsol/dense/sunlinsol_dense.o stan/lib/stan_math/lib/sundials_5.2.0/src/sunmatrix/band/sunmatrix_band.o stan/lib/stan_math/lib/sundials_5.2.0/src/sunmatrix/dense/sunmatrix_dense.o stan/lib/stan_math/lib/sundials_5.2.0/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.o stan/lib/stan_math/lib/sundials_5.2.0/src/sunnonlinsol/newton/sunnonlinsol_newton.o
  cleaning Intel TBB targets
rm -f -rf stan/lib/stan_math/lib/tbb
rm -f bin/stanc.exe bin/stanc2.exe bin/stansummary.exe bin/print.exe bin/diagnose.exe
rm -f -r src/cmdstan/main*.o bin/cmdstan
rm -f stan/src/stan/model/model_header.hpp.gch
rm -f examples/bernoulli/bernoulli.exe examples/bernoulli/bernoulli.o examples/bernoulli/bernoulli.d examples/bernoulli/bernoulli.hpp
rm -f -r stan/lib/stan_math/lib/boost_1.72.0/stage/lib stan/lib/stan_math/lib/boost_1.72.0/bootstrap.log
Informationÿ: impossible de trouver des fichiers pour le(s) modŠle(s) sp‚cifi‚(s).
cp bin/windows-stanc bin/stanc.exe
cd stan/lib/stan_math/lib/boost_1.72.0; ./bootstrap.bat gcc
.
.
.

g++ -c -MMD -O2 -DUSE_WINTHREAD -D_WIN32_WINNT=0x0502 -DMINGW_HAS_SECURE_API=1 -D__MSVCRT_VERSION__=0x0700 -msse -mthreads -m64 -mrtm    -fno-rtti -fno-exceptions -D__TBBMALLOC_BUILD=1 -Wno-parentheses -Wno-uninitialized -Wno-non-virtual-dtor  -flifetime-dse=1 -I../tbb_2019_U8/src -I../tbb_2019_U8/src/rml/include -I../tbb_2019_U8/include -I../tbb_2019_U8/src/tbbmalloc -I../tbb_2019_U8/src/tbbmalloc -I. ../tbb_2019_U8/src/tbbmalloc/frontend.cpp
gcc  -o tbbmalloc.dll backend.o large_objects.o backref.o  tbbmalloc.o  itt_notify_malloc.o frontend.o   -lpsapi -shared -m64 -Wl,-L,"C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb" -Wl,--version-script,tbbmalloc.def
C:/Program Files/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find C:/Program: No such file or directory
C:/Program Files/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find Files/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/lib/../lib/default-manifest.o: No such file or directory
collect2.exe: error: ld returned 1 exit status
g++  -o tbbmalloc_proxy.dll proxy.o tbb_function_replacement.o   -lpsapi tbbmalloc.dll  -shared -m64 -Wl,-L,"C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb"
Fichier introuvable

Failed to build Boost.Build engine.
Please consult bootstrap.log for further diagnostics.

mingw32-make[1]: Leaving directory 'C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb'
mingw32-make.exe: *** [make/command:35: stan/lib/stan_math/lib/boost_1.72.0/stage/lib/libboost_program_options*.a] Error 1
mingw32-make.exe: *** Waiting for unfinished jobs....
touch stan/lib/stan_math/lib/tbb/version_tbb_2019_U8
tbb_root="../tbb_2019_U8" CXX="g++" CC="gcc" LDFLAGS='-Wl,-L,"C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb"' mingw32-make.exe -C "stan/lib/stan_math/lib/tbb" -r -f "C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb_2019_U8/build/Makefile.tbb" compiler=gcc cfg=release stdver=c++1y
mingw32-make[1]: Entering directory 'C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb'
C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb_2019_U8/build/Makefile.tbb:28: CONFIG: cfg=release arch=intel64 compiler=gcc target=windows runtime=mingw8.3.0
g++ -o concurrent_hash_map.o -c -MMD -O2 -DUSE_WINTHREAD -D_WIN32_WINNT=0x0502 -DMINGW_HAS_SECURE_API=1 -D__MSVCRT_VERSION__=0x0700 -msse -mthreads -m64 -mrtm   -flifetime-dse=1 -D__TBB_BUILD=1 -Wall -Wno-parentheses -Wno-uninitialized -Wno-non-virtual-dtor  -std=c++1y  -I../tbb_2019_U8/src -I../tbb_2019_U8/src/rml/include -I../tbb_2019_U8/include ../tbb_2019_U8/src/tbb/concurrent_hash_map.cpp
.
.
.
task.o: duplicate section `.rdata$_ZTIN3tbb4taskE[_ZTIN3tbb4taskE]' has different size
arena.o: duplicate section `.rdata$_ZTIN3tbb4taskE[_ZTIN3tbb4taskE]' has different size
scheduler.o: duplicate section `.rdata$_ZTIN3tbb4taskE[_ZTIN3tbb4taskE]' has different size
mingw32-make[1]: Leaving directory 'C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb'

In line 7, it says “Information: Unable to find files for the specified models”. It has weird characters in it, but that is what I think it says.
In this chunk, “Fichier introuvable” means “Unable to find file”:

g++  -o tbbmalloc_proxy.dll proxy.o tbb_function_replacement.o   -lpsapi tbbmalloc.dll  -shared -m64 -Wl,-L,"C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb"
Fichier introuvable

Again, sorry for the French.

I re-ran the example model and I get the same error as before.

In this case the space in Program Files indeed the issue. Can you reinstall it to the default location and rerun this line afterwards

writeLines('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', con = "~/.Renviron")

and then try again.

1 Like

Seemed to have worked smoothly!

At the end of running rebuild_cmdstan(), it says

NOTE: Please add C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb to your PATH variable.
You may call mingw32-make install-tbb to automatically update your user configuration.

I assume

writeLines('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', con = "~/.Renviron")

took care of that?

@rok_cesnovar, @bgoodri, @jonah, @stevebronder Thank you all very much for your help with my relatively trivial issues, I appreciate it!
Cheers

1 Like

Not a problem at all, it was not your fault. You can ignore the above warning, this is printed on install, but cmdstanr handles that automatically.

Cheers

2 Likes

When I installed the newest rstan, I seem to have this error:

> schools_dat <- list(J = 8, 
+                     y = c(28,  8, -3,  7, -1,  1, 18, 12),
+                     sigma = c(15, 10, 16, 11,  9, 11, 10, 18))
> fit <- stan(file = 'C:\\schools.stan', data = schools_dat)
Error in withr::set_makevars(new, path, state, assignment = assignment) : 
  Multiple results for CXX14FLAGS found, something is wrong.FALSE
In addition: Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
  'C:/Rtools/mingw_/bin/g++' not found

There must be multiple CXX14FLAGS entries in your Makevars.win or Makevars file. What comes up if you check those files like this?

file.edit(file.path(Sys.getenv("HOME"), ".R", "Makevars.win"))
file.edit(file.path(Sys.getenv("HOME"), ".R", "Makevars"))
1 Like