Mingw32-make build "Could not find files for the given pattern(s)."

R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

I’m trying to install stan following the instructions here.

I downloaded the RTools42 installer and ran it.
(At some point I also tried RTools40, but it didn’t work for me, so uninstalled it again.)

I added C:\rtools42\usr\bin to PATH, but found that c++.exe and g++.exe were located in C:\rtools42\x86_64-w64-mingw32.static.posix\bin , so I added this to PATH as well. My PATH is now pretty crowded:

Sys.getenv(“PATH”)
[1] “C:\rtools42/x86_64-w64-mingw32.static.posix/bin;C:\rtools42/usr/bin;\usr\bin;\usr\bin;C:\Program Files\R\R-4.2.1\bin\x64;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\Calibre2\;C:\Program Files\dotnet\;C:\Program Files\Git\cmd;C:\Users\janfl\AppData\Local\activestate\cache\bin;C:\Users\janfl\AppData\Local\ActiveState\StateTool\release\bin;C:\Users\janfl\AppData\Local\Microsoft\WindowsApps;C:\texlive\2021\bin\win32;C:\Program Files\JetBrains\PyCharm Community Edition 2021.3.1\bin;;C:\Users\janfl\AppData\Local\Programs\Microsoft VS Code\bin;C:\rtools42\x86_64-w64-mingw32.static.posix\bin;C:\rtools42\usr\bin;C:\rtools42;C:\MinGW\bin;;C:/Program Files/RStudio/resources/app/bin/quarto/bin”

I found that RTools42 did not contain mingw32-make.exe, so I installed MinGW from sourceforge.

When I now run mingw32-make build in the command line in the cmdstan-2.30.1 folder, I get the following error message. I suppose it might be related to this problem here. Would really appreciate help.

INFO: Could not find files for the given pattern(s).
if ! [[ mingw32-make =~ mingw32 ]]; then
echo “ERROR: Please use mingw32-make on Windows to build the Intel TBB library.”;
echo “This is packaged with RTools, for example.”;
exit 1;
fi
touch stan/lib/stan_math/lib/tbb/tbb-make-check
tbb_root=“…/tbb_2020.3” CXX=“g++” CC=“gcc” LDFLAGS='-Wl,-L,“C:/Users/janfl/Desktop/cmdstan-2.30.1/stan/lib/stan_math/lib/tbb” -Wl,-rpath,“C:/Users/janfl/Desktop/cmdstan-2.30.1/stan/lib/stan_math/lib/tbb” ’ ‘mingw32-make’ -C “stan/lib/stan_math/lib/tbb” -r -f “C:/Users/janfl/Desktop/cmdstan-2.30.1/stan/lib/stan_math/lib/tbb_2020.3/build/Makefile.tbbmalloc” compiler=gcc cfg=release stdver=c++1y malloc CXXFLAGS="-Wno-unknown-warning-option -Wno-deprecated-copy -Wno-missing-attributes -Wno-class-memaccess -Wno-sized-deallocation "
mingw32-make[1]: Entering directory ‘C:/Users/janfl/Desktop/cmdstan-2.30.1/stan/lib/stan_math/lib/tbb’
g++ -c -MMD -O2 -DUSE_WINTHREAD -D_WIN32_WINNT=0x0502 -DMINGW_HAS_SECURE_API=1 -D__MSVCRT_VERSION__=0x0700 -msse -mthreads -m64 -mrtm -Wno-unknown-warning-option -Wno-deprecated-copy -Wno-missing-attributes -Wno-class-memaccess -Wno-sized-deallocation -DTBB_SUPPRESS_DEPRECATED_MESSAGES=1 -fno-rtti -fno-exceptions -D__TBBMALLOC_BUILD=1 -Wno-parentheses -Wno-uninitialized -Wno-non-virtual-dtor -flifetime-dse=1 -I…/tbb_2020.3/src -I…/tbb_2020.3/src/rml/include -I…/tbb_2020.3/include -I…/tbb_2020.3/src/tbbmalloc -I…/tbb_2020.3/src/tbbmalloc …/tbb_2020.3/src/tbbmalloc/backend.cpp
In file included from c:\rtools42\x86_64-w64-mingw32.static.posix\lib\gcc\x86_64-w64-mingw32.static.posix\10.4.0\include\c++\stdlib.h:36,
from c:\rtools42\x86_64-w64-mingw32.static.posix\lib\gcc\x86_64-w64-mingw32.static.posix\10.4.0\include\mm_malloc.h:27,
from c:\rtools42\x86_64-w64-mingw32.static.posix\lib\gcc\x86_64-w64-mingw32.static.posix\10.4.0\include\xmmintrin.h:34,
from c:\rtools42\x86_64-w64-mingw32.static.posix\lib\gcc\x86_64-w64-mingw32.static.posix\10.4.0\include\immintrin.h:29,
from …/tbb_2020.3/include/tbb/machine/gcc_itsx.h:57,
from …/tbb_2020.3/include/tbb/machine/gcc_ia32_common.h:107,
from …/tbb_2020.3/include/tbb/machine/gcc_generic.h:232,
from …/tbb_2020.3/include/tbb/tbb_machine.h:197,
from …/tbb_2020.3/src/tbbmalloc/Synchronize.h:20,
from …/tbb_2020.3/src/tbbmalloc/Customize.h:29,
from …/tbb_2020.3/src/tbbmalloc/TypeDefinitions.h:54,
from …/tbb_2020.3/src/tbbmalloc/tbbmalloc_internal.h:21,
from …/tbb_2020.3/src/tbbmalloc/backend.cpp:19:
c:\rtools42\x86_64-w64-mingw32.static.posix\lib\gcc\x86_64-w64-mingw32.static.posix\10.4.0\include\c++\cstdlib:137:11: error: ‘at_quick_exit’ has not been declared in ‘::’
137 | using ::at_quick_exit;
| ^~~~~~~~~~~~~
c:\rtools42\x86_64-w64-mingw32.static.posix\lib\gcc\x86_64-w64-mingw32.static.posix\10.4.0\include\c++\cstdlib:160:11: error: ‘quick_exit’ has not been declared in ‘::’
160 | using ::quick_exit;
| ^~~~~~~~~~
In file included from c:\rtools42\x86_64-w64-mingw32.static.posix\lib\gcc\x86_64-w64-mingw32.static.posix\10.4.0\include\mm_malloc.h:27,
from c:\rtools42\x86_64-w64-mingw32.static.posix\lib\gcc\x86_64-w64-mingw32.static.posix\10.4.0\include\xmmintrin.h:34,
from c:\rtools42\x86_64-w64-mingw32.static.posix\lib\gcc\x86_64-w64-mingw32.static.posix\10.4.0\include\immintrin.h:29,
from …/tbb_2020.3/include/tbb/machine/gcc_itsx.h:57,
from …/tbb_2020.3/include/tbb/machine/gcc_ia32_common.h:107,
from …/tbb_2020.3/include/tbb/machine/gcc_generic.h:232,
from …/tbb_2020.3/include/tbb/tbb_machine.h:197,
from …/tbb_2020.3/src/tbbmalloc/Synchronize.h:20,
from …/tbb_2020.3/src/tbbmalloc/Customize.h:29,
from …/tbb_2020.3/src/tbbmalloc/TypeDefinitions.h:54,
from …/tbb_2020.3/src/tbbmalloc/tbbmalloc_internal.h:21,
from …/tbb_2020.3/src/tbbmalloc/backend.cpp:19:
c:\rtools42\x86_64-w64-mingw32.static.posix\lib\gcc\x86_64-w64-mingw32.static.posix\10.4.0\include\c++\stdlib.h:43:14: error: ‘at_quick_exit’ has not been declared in ‘std’
43 | using std::at_quick_exit;
| ^~~~~~~~~~~~~
c:\rtools42\x86_64-w64-mingw32.static.posix\lib\gcc\x86_64-w64-mingw32.static.posix\10.4.0\include\c++\stdlib.h:46:14: error: ‘quick_exit’ has not been declared in ‘std’
46 | using std::quick_exit;
| ^~~~~~~~~~
cc1plus.exe: note: unrecognized command-line option ‘-Wno-unknown-warning-option’ may have been intended to silence earlier diagnostics
C:/Users/janfl/Desktop/cmdstan-2.30.1/stan/lib/stan_math/lib/tbb_2020.3/build/Makefile.tbbmalloc:65: recipe for target ‘backend.o’ failed
mingw32-make[1]: *** [backend.o] Error 1
mingw32-make[1]: Leaving directory ‘C:/Users/janfl/Desktop/cmdstan-2.30.1/stan/lib/stan_math/lib/tbb’
stan/lib/stan_math/make/libraries:172: recipe for target ‘stan/lib/stan_math/lib/tbb/tbbmalloc.def’ failed
mingw32-make: *** [stan/lib/stan_math/lib/tbb/tbbmalloc.def] Error 2

To use RTools42 with cmdstan you need to create a make/local file in your cmdstan directory and add the entries:

CXXFLAGS += -Wno-nonnull
 TBB_CXXFLAGS= -U__MSVCRT_VERSION__ -D__MSVCRT_VERSION__=0x0E00
1 Like

Thank you for your help.

I did this and it changed the effect of ‘mingw32-make build’.

After the compilation (a few minutes) I was asked to add ‘\cmdstan-2.30.1\stan\lib\stan_math\lib\tbb’ (with forwardslash instead of backslash, which I adjusted) to PATH.

After doing this, I tried: ‘mingw32-make examples/bernoulli/bernoulli.exe’ as indicated here in cmdstan-2.30.1 and got the following error:

g++ -Wno-nonnull -std=c++1y -m64 -D_REENTRANT -Wall -Wno-unused-function -Wno-uninitialized -Wno-unused-but-set-variable -Wno-unused-variable -Wno-sign-compare -Wno-unused-local-typedefs -Wno-int-in-bool-context -Wno-attributes -Wno-ignored-attributes -I stan/lib/stan_math/lib/tbb_2020.3/include -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.78.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials -D_USE_MATH_DEFINES -DBOOST_DISABLE_ASSERTS -c -MT stan/src/stan/model/model_header.hpp.gch -MT stan/src/stan/model/model_header.d -M -E -MG -MP -MF stan/src/stan/model/model_header.d stan/src/stan/model/model_header.hpp
g++ -Wno-nonnull -std=c++1y -m64 -D_REENTRANT -Wall -Wno-unused-function -Wno-uninitialized -Wno-unused-but-set-variable -Wno-unused-variable -Wno-sign-compare -Wno-unused-local-typedefs -Wno-int-in-bool-context -Wno-attributes -Wno-ignored-attributes -I stan/lib/stan_math/lib/tbb_2020.3/include -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.78.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials -D_USE_MATH_DEFINES -DBOOST_DISABLE_ASSERTS -c -MT src/cmdstan/main.o -M -E -MG -MP -MF src/cmdstan/main.d src/cmdstan/main.cpp

— Translating Stan model to C++ code —
bin/stanc.exe --o=examples/bernoulli/bernoulli.hpp examples/bernoulli/bernoulli.stan

— Compiling, linking C++ code —
g++ -Wno-nonnull -std=c++1y -m64 -D_REENTRANT -Wall -Wno-unused-function -Wno-uninitialized -Wno-unused-but-set-variable -Wno-unused-variable -Wno-sign-compare -Wno-unused-local-typedefs -Wno-int-in-bool-context -Wno-attributes -Wno-ignored-attributes -I stan/lib/stan_math/lib/tbb_2020.3/include -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.78.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials -D_USE_MATH_DEFINES -DBOOST_DISABLE_ASSERTS -c -Wno-ignored-attributes -x c++ -o examples/bernoulli/bernoulli.o examples/bernoulli/bernoulli.hpp

make/program:56: recipe for target ‘examples/bernoulli/bernoulli.exe’ failed
mingw32-make: *** [examples/bernoulli/bernoulli.exe] Error 1

I looked around and also did not find bernoulli.exe in the bernoulli folder. Would you be so kind as to help me with this problem, too?

I can’t see any other errors in there. Can you clean and rebuild cmdstan and then try again?

mingw32-make clean
mingw32-make build
1 Like

I’m absolutely new to stan (and much of what I needed to do to get it installed), but I think it worked.
Now I can focus on the conceptual aspects again. Thank you so much!