When trying to use the new infrastructure to expose model methods with cmdstanr 0.6 on Windows 10, R 4.3.1 and Rtools 4.3 I get the following message:
Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared object 'C:/Users/modrak_m/AppData/Local/Temp/Rtmp0I5pke/sourceCpp-x86_64-w64-mingw32-1.0.11/sourcecpp_2efc1c0271b6/sourceCpp_4.dll':
LoadLibrary failure: The specified module could not be found.
This is true whether I try to do this via cmdstan_model(file, compile_model_methods = TRUE) or via fit$init_model_methods()
A general point: this type of message comes from Windows means that some DLL somewhere in the dependency chain of the library that we are trying to load cannot be found. Unhelpfully, it doesn’t say which DLL.
After some digging and scanning the dependency trees of the generated DLL, I’ve found that I need to add the following directory to PATH:
C:\rtools43\ucrt64\bin
(obviously if you have non-default location for Rtools 4.3 installation, use that). I’ve done that in the .Renviron file, so my .Renviron now looks like this:
PATH="C:\rtools43\ucrt64\bin;${PATH}"
The dependency on the libraries under ucrt64/bin seems new to Rtools4.3, I didn’t have any such problem with Rtools 4.2
It’s a little odd that this is happening when compiling the model-methods, since R automatically handles path-setting for RTools from 4.2+.
Is adding the path to TBB also required here (i.e., both rtools and TBB need to be in the path)?
It’s a pretty easy fix to have cmdstanr automatically add entries to the PATH when compiling and loading model methods. I’ll add that to my to-do list for this week.
Oh, I didn’t check the install instructions as check_cmdstan_toolchain() showed no problems and I could compile and run models just fine. I’ve only hit those problems when compiling model methods/standalone functions (which I was both able to run succesfully without the added PATH on 4.2).
Appears that TBB is no longer required, it is a relict from earlier days that I was just too afraid to remove :-D. Edited above to avoid confusing others.