I am running this code
-----------------------------------------------------------------------------------------------
file <- file.path(cmdstan_path(), "examples", "bernoulli", "bernoulli.stan")
mod <- cmdstan_model(file)
-----------------------------------------------------------------------------------------------
unsuccessfully in this environment
-----------------------------------------------------------------------------------------------
R version 4.4.1 (2024-06-14 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.utf8
[2] LC_CTYPE=English_United States.utf8
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8
time zone: America/New_York
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] bayesplot_1.11.1 posterior_1.6.0 cmdstanr_0.8.1
loaded via a namespace (and not attached):
[1] gtable_0.3.6 jsonlite_1.8.8 dplyr_1.1.4
[4] compiler_4.4.1 tidyselect_1.2.1 scales_1.3.0
[7] yaml_2.3.10 fastmap_1.2.0 ggplot2_3.5.1
[10] R6_2.5.1 generics_0.1.3 distributional_0.5.0
[13] knitr_1.48 backports_1.5.0 checkmate_2.3.2
[16] tibble_3.2.1 munsell_0.5.1 pillar_1.9.0
[19] rlang_1.1.4 utf8_1.2.4 xfun_0.46
[22] cli_3.6.3 withr_3.0.2 magrittr_2.0.3
[25] ps_1.7.7 digest_0.6.36 grid_4.4.1
[28] processx_3.8.4 rstudioapi_0.16.0 lifecycle_1.0.4
[31] vctrs_0.6.5 evaluate_0.24.0 glue_1.7.0
[34] tensorA_0.36.2.1 abind_1.4-8 fansi_1.0.6
[37] colorspace_2.1-1 rmarkdown_2.27 tools_4.4.1
[40] pkgconfig_2.0.3 htmltools_0.5.8.1
-----------------------------------------------------------------------------------------------
and get this compilation error
-----------------------------------------------------------------------------------------------
Compiling Stan program... C:/RBuildTools/4.4/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe : src/cmdstan/main.o:main.cpp:(.text$_ZN4stan2io15stan_csv_reader15read_adaptationERSiRNS0_19stan_csv_adaptationE[_ZN4stan2io15stan_csv_reader15read_adaptationERSiRNS0_19stan_csv_adaptationE]+0x1c0): undefined reference to `std::istream::seekg(std::fpos<int>)' C:/RBuildTools/4.4/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe : src/cmdstan/main.o:main.cpp:(.text$_ZN4stan2io15stan_csv_reader12read_samplesERSiRN5Eigen6MatrixIdLin1ELin1ELi0ELin1ELin1EEERNS0_15stan_csv_timingE[_ZN4stan2io15stan_csv_reader12read_samplesERSiRN5Eigen6MatrixIdLin1ELin1ELi0ELin1ELin1EEERNS0_15stan_csv_timingE]+0x690): undefined reference to `std::istream::seekg(std::fpos<int>)' C:/RBuildTools/4.4/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: src/cmdstan/main.o:main.cpp:(.text$_ZN4stan2io15stan_csv_reader13read_metadataERSiRNS0_17stan_csv_metadataE[_ZN4stan2io15stan_csv_reader13read_metadataERSiRNS0_17stan_csv_metadataE]+0xe3): undefined reference to `std::istream::seekg(std::fpos<int>)' collect2.exe: error: ld returned 1 exit status mingw32-make: *** [make/program:82: C:/Users/wgfoo/AppData/Local/Temp/RtmpMTcVuJ/model-138bc72c048b1.exe] Error 1
[image] Show Traceback
Error: An error occured during compilation! See the message above for more information.
----------------------------------------------------------------------------
When I ran this, and other models, using this environment on 2024-12-19, all worked perfectly well. And today models using the rethinking::ulam(, cmdstan=TRUE) run perfectly as well.run
For comparison purposes, this code runs, as advertised,
--------------------------------------------------------------------------
example(stan_model, package = "rstan", run.dontrun = TRUE)
--------------------------------------------------------------------------
with make cmd processing
--------------------------------------------------------------------------
make cmd is
make -f "C:/PROGRA~1/R/R-44~1.1/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-44~1.1/share/make/winshlib.mk" CXX='$(CXX17) $(CXX17STD)' CXXFLAGS='$(CXX17FLAGS)' CXXPICFLAGS='$(CXX17PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX17LDFLAGS)' SHLIB_LD='$(SHLIB_CXX17LD)' SHLIB="file138bc2c2717e1.dll" WIN=64 TCLBIN= OBJECTS="file138bc2c2717e1.o"
make would use
g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-44~1.1/include" -DNDEBUG -I"C:/Users/wgfoo/AppData/Local/R/win-library/4.4/Rcpp/include/" -I"C:/Users/wgfoo/AppData/Local/R/win-library/4.4/RcppEigen/include/" -I"C:/Users/wgfoo/AppData/Local/R/win-library/4.4/RcppEigen/include/unsupported" -I"C:/Users/wgfoo/AppData/Local/R/win-library/4.4/BH/include" -I"C:/Users/wgfoo/AppData/Local/R/win-library/4.4/StanHeaders/include/src/" -I"C:/Users/wgfoo/AppData/Local/R/win-library/4.4/StanHeaders/include/" -I"C:/Users/wgfoo/AppData/Local/R/win-library/4.4/RcppParallel/include/" -DRCPP_PARALLEL_USE_TBB=1 -I"C:/Users/wgfoo/AppData/Local/R/win-library/4.4/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DUSE_STANC3 -DSTRICT_R_HEADERS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -D_HAS_AUTO_PTR_ETC=0 -include "C:/Users/wgfoo/AppData/Local/R/win-library/4.4/StanHeaders/include/stan/math/prim/fun/Eigen.hpp" -std=c++1y -I"C:/RBuildTools/4.4/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c file138bc2c2717e1.cpp -o file138bc2c2717e1.o
if test "zfile138bc2c2717e1.o" != "z"; then \
if test -e "file138bc2c2717e1-win.def"; then \
echo g++ -shared -s -static-libgcc -o file138bc2c2717e1.dll file138bc2c2717e1-win.def file138bc2c2717e1.o "C:/Users/wgfoo/AppData/Local/R/win-library/4.4/rstan/lib/x64/libStanServices.a" -L"C:/Users/wgfoo/AppData/Local/R/win-library/4.4/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/wgfoo/AppData/Local/R/win-library/4.4/RcppParallel/lib/x64" -ltbb -LC:/Users/wgfoo/AppData/Local/R/win-library/4.4/RcppParallel/lib/x64 -ltbb -ltbbmalloc -L"C:/RBuildTools/4.4/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/RBuildTools/4.4/x86_64-w64-mingw32.static.posix/lib" -L"C:/PROGRA~1/R/R-44~1.1/bin/x64" -lR ; \
g++ -shared -s -static-libgcc -o file138bc2c2717e1.dll file138bc2c2717e1-win.def file138bc2c2717e1.o "C:/Users/wgfoo/AppData/Local/R/win-library/4.4/rstan/lib/x64/libStanServices.a" -L"C:/Users/wgfoo/AppData/Local/R/win-library/4.4/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/wgfoo/AppData/Local/R/win-library/4.4/RcppParallel/lib/x64" -ltbb -LC:/Users/wgfoo/AppData/Local/R/win-library/4.4/RcppParallel/lib/x64 -ltbb -ltbbmalloc -L"C:/RBuildTools/4.4/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/RBuildTools/4.4/x86_64-w64-mingw32.static.posix/lib" -L"C:/PROGRA~1/R/R-44~1.1/bin/x64" -lR ; \
else \
echo EXPORTS > tmp.def; \
nm file138bc2c2717e1.o | sed -n 's/^.* [BCDRT] / /p' | sed -e '/[.]refptr[.]/d' -e '/[.]weak[.]/d' | sed 's/[^ ][^ ]*/"&"/g' >> tmp.def; \
echo g++ -shared -s -static-libgcc -o file138bc2c2717e1.dll tmp.def file138bc2c2717e1.o "C:/Users/wgfoo/AppData/Local/R/win-library/4.4/rstan/lib/x64/libStanServices.a" -L"C:/Users/wgfoo/AppData/Local/R/win-library/4.4/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/wgfoo/AppData/Local/R/win-library/4.4/RcppParallel/lib/x64" -ltbb -LC:/Users/wgfoo/AppData/Local/R/win-library/4.4/RcppParallel/lib/x64 -ltbb -ltbbmalloc -L"C:/RBuildTools/4.4/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/RBuildTools/4.4/x86_64-w64-mingw32.static.posix/lib" -L"C:/PROGRA~1/R/R-44~1.1/bin/x64" -lR ; \
g++ -shared -s -static-libgcc -o file138bc2c2717e1.dll tmp.def file138bc2c2717e1.o "C:/Users/wgfoo/AppData/Local/R/win-library/4.4/rstan/lib/x64/libStanServices.a" -L"C:/Users/wgfoo/AppData/Local/R/win-library/4.4/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/wgfoo/AppData/Local/R/win-library/4.4/RcppParallel/lib/x64" -ltbb -LC:/Users/wgfoo/AppData/Local/R/win-library/4.4/RcppParallel/lib/x64 -ltbb -ltbbmalloc -L"C:/RBuildTools/4.4/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/RBuildTools/4.4/x86_64-w64-mingw32.static.posix/lib" -L"C:/PROGRA~1/R/R-44~1.1/bin/x64" -lR ; \
rm -f tmp.def; \
fi \
fi
-------------------------------------------------------------------------------------
in this environment
--------------------------------------------------------------------------
R version 4.4.1 (2024-06-14 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.utf8
[2] LC_CTYPE=English_United States.utf8
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8
time zone: America/New_York
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rstan_2.32.6 StanHeaders_2.32.10 bayesplot_1.11.1
[4] posterior_1.6.0 cmdstanr_0.8.1
loaded via a namespace (and not attached):
[1] tensorA_0.36.2.1 utf8_1.2.4 generics_0.1.3
[4] digest_0.6.36 magrittr_2.0.3 evaluate_0.24.0
[7] grid_4.4.1 fastmap_1.2.0 jsonlite_1.8.8
[10] processx_3.8.4 pkgbuild_1.4.4 backports_1.5.0
[13] ps_1.7.7 gridExtra_2.3 fansi_1.0.6
[16] QuickJSR_1.4.0 scales_1.3.0 codetools_0.2-20
[19] abind_1.4-8 cli_3.6.3 rlang_1.1.4
[22] munsell_0.5.1 withr_3.0.2 yaml_2.3.10
[25] parallel_4.4.1 tools_4.4.1 inline_0.3.19
[28] checkmate_2.3.2 dplyr_1.1.4 colorspace_2.1-1
[31] ggplot2_3.5.1 curl_5.2.1 vctrs_0.6.5
[34] R6_2.5.1 matrixStats_1.3.0 stats4_4.4.1
[37] lifecycle_1.0.4 V8_4.4.2 pkgconfig_2.0.3
[40] RcppParallel_5.1.9 pillar_1.9.0 gtable_0.3.6
[43] loo_2.8.0 glue_1.7.0 Rcpp_1.0.13
[46] xfun_0.46 tibble_3.2.1 tidyselect_1.2.1
[49] rstudioapi_0.16.0 knitr_1.48 htmltools_0.5.8.1
[52] rmarkdown_2.27 compiler_4.4.1 distributional_0.5.0
---------------------------------------------------------------------------------------
Previous posts from 2022 did not solve my problem. I rebooted, reinstalled, updated, etc. to no avail. There appears to be no interactive process at work either (the typical collect2.exe error issue). An obvious difference between the rstan and cmdstanr runs is the location of g++.
Any thoughts on next steps? Much thanks, Bill