-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
problem exporting Rcpp functions #13
Comments
I'm having the same issue but deleting this block of code doesn't fix it. I used rstanstools::rstan_package_skeleton to setup a package and added the default timesTwo.cpp to the package. I'm getting the error
I'd like to have a package to fit a model using RStan and then use an RcppArmadillo function to post-process the data. I can't find any documentation referring to implementing stand-alone Rcpp functions within an RStan package. Any help would be appreciated. |
There isn't documentation for that in rstantools because no one else (that
I know of) has wanted to try, it is usually a better idea to put stuff like
that into the generated quantities block of your Stan programs, and doing
so presumably just involves adding the usual stuff for a package that uses
RcppArmadillo on top of what is generated by
`rstantools::rstan_package_skeleton`.
…On Wed, May 30, 2018 at 1:26 PM, jtipton25 ***@***.***> wrote:
I'm having the same issue but deleting this block of code doesn't fix it.
I used rstanstools::rstan_package_skeleton to setup a package and added
the default timesTwo.cpp to the package. I'm getting the error
Error in timesTwo(rnorm(10)) : object '_test_timesTwo' not found
I'd like to have a package to fit a model using RStan and then use an
RcppArmadillo function to post-process the data. I can't find any
documentation referring to implementing stand-alone Rcpp functions within
an RStan package. Any help would be appreciated.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#13 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADOrqpLfco802dlh8kwj6KtWYD-HmgL7ks5t3tZDgaJpZM4PlwYA>
.
|
This is a problem that should probably be fixed. Putting code in generated quantities block is very limiting. |
I agree with above. I'm trying to make a package that includes simulations using Rcpp, and having those functions in generated quantities blocks instead of their own .cpp files is a real problem. |
I would also need RcppArmadillo to work in a package created using Rstantools. I have the same problem: object [name of function] not found |
I have successfully combined external C++ and Stan models in the same package in the past (https://github.com/helske/walker), but I just started to update some stuff and something has changed so that I new I get an infinite recompilation loops... And if I switch to newer package skeleton structure, I also face the issue that either Stan models or other C++ functions are not getting exported (depending on how I tweak Makevars etc). |
I think roxygen2 changed its behavior, so you should not have your package
rebuild your manpages inside the cleanup function.
…On Fri, Oct 12, 2018 at 4:52 PM Jouni Helske ***@***.***> wrote:
I have successfully combined external C++ and Stan models in the same
package in the past (https://github.com/helske/walker), but I just
started to update some stuff and something has changed so that I new I get
an infinite recompilation loops... And if I switch to newer package
skeleton structure, I also face the issue that either Stan models or other
C++ functions are not getting exported (depending on how I tweak Makevars
etc).
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#13 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADOrqgG2DxnLGbjZNaZ4kq6QNoWPk9xsks5ukQD6gaJpZM4PlwYA>
.
|
Yes I just realized that as well, removing the roxygen line fixed the infinite loop issue and the package compiles. But the Stan models are not getting exported. Investigation continues... edit: Oops, I had a wrong version of the |
Do you have something like this in your zzz.R?
https://github.com/stan-dev/rstanarm/blob/master/R/zzz.R#L18
…On Fri, Oct 12, 2018 at 5:11 PM Jouni Helske ***@***.***> wrote:
Yes I just realized that as well, removing the roxygen line fixed the
infinite loop issue and the package compiles. But the Stan models are not
getting exported. Investigation continues...
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#13 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADOrqoAlaNeg901_KZg5_HaQqbw2ddefks5ukQVlgaJpZM4PlwYA>
.
|
I encountered the same problem today, that I couldn't use Rcpp functions in a package generated with I found that removing the I solved this issue by adding
which makes sure that the dynamic symbol is accessible in the So in conclusion, replacing the |
Nice. There may be other solutions but I am glad you found one. Be sure to
read
https://discourse.mc-stan.org/t/how-to-update-a-package-that-has-stanheaders-and-rstan-in-its-linkingto/6041?u=bgoodri
for how to get it to work with rstan 2.18.1.
…On Tue, Oct 23, 2018 at 12:56 PM Constantin ***@***.***> wrote:
I encountered the same problem today, that I couldn't use Rcpp functions
in a package generated with rstanstools::rstan_package_skeleton.
I found that removing the R_init_mypackage function fixes the problem of
calling the Rcpp functions, because the function is then generated by Rcpp
in RcppExports.cpp. But I got another error when I loaded the package
that "object 'm' not found" as described in issue #43
<#43>.
I solved this issue by adding
// [[Rcpp::init]]
void rstan_additional_init(DllInfo *dll){
R_useDynamicSymbols(dll, TRUE); // necessary for .onLoad() to work
}
which makes sure that the dynamic symbol is accessible in the .onLoad
function in zzz.R.
So in conclusion, replacing the R_init_mypackage function with the code
above fixed my problem.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#13 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADOrqjXMmZWvWiv1UtjUaPz54wn-ESpXks5un0osgaJpZM4PlwYA>
.
|
Just a quick comment to add to @const-ae, encountered the same issue and had some trouble getting it to work, in addition to @const-ae suggestion that were required. A few quick notes that would have helped me. You also need to include RcppExports.o and the other Rcpp source files in the sources variable of Makevars (and I assume Makevars.win but have not tested that) |
I want to make a C++ function aviliable to R with the
// [[Rcpp::export]]
command. This does not work when using the rstan.package.skeleton. I get the error "object '[name of the rcpp function]' not found". It appears to be some problem with registering the routine.However, if I remove lines 16:20 from src\init.cpp the registration works. Here is the code from those lines:
What do these lines of code actually do and are they safe to remove?
The text was updated successfully, but these errors were encountered: