Skip to content
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

Fix NAMESPACE / usedynlib issue for package compilation #1

Closed
gmgeorg opened this issue Jun 3, 2020 · 1 comment
Closed

Fix NAMESPACE / usedynlib issue for package compilation #1

gmgeorg opened this issue Jun 3, 2020 · 1 comment

Comments

@gmgeorg
Copy link
Owner

@gmgeorg gmgeorg commented Jun 3, 2020

After updates in build process in Rcpp packages the previous roxygen2 tags didnt work anymore properly. I tried following steps in https://stackoverflow.com/questions/58132832/error-function-is-not-available-for-call-for-package-x but that didnt work out properly.

Note that in v0.6.4 the NAMESPACE file used only useDynLib; recently CRAN wants the .registration=TRUE flag added. This lies at the root of not being able to compile the package anymore. Its somehow related to the .registration flag causing problems with function names not being found anymore. I think (!) this has to do with a name clash between RCPP and R function names that share the same name (described here about KernSmooth package https://cran.r-project.org/doc/manuals/r-release/R-exts.html) . Not sure how to resolve this since I am going in circles about having to add .registration=TRUE to compile properly and pass CRAN chekcs, but then function names not being found.

@gmgeorg
Copy link
Owner Author

@gmgeorg gmgeorg commented Jun 7, 2020

This was fixed by commenting out the .onLoad and .onUnload functions in `zzz.R (thanks to Kurt Hornik for pointing this out).

background for future reference (or any Google search that might run into same issue)
The underlying issue was with the RegisterCallable functions not being in the right place in the RcppExports file. Before suggesting the onload/onunload fix, Kurt Hornik pointed out that moving the R_RegisterCCallable function into the R_init_LambertW fixes the insallation of package problems:

RcppExport void R_init_LambertW(DllInfo *dll) {
    R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
    R_useDynamicSymbols(dll, FALSE);
    R_RegisterCCallable("LambertW", "_LambertW_W_Cpp", (DL_FUNC)_LambertW_W_Cpp_try);
    R_RegisterCCallable("LambertW", "_LambertW_W_delta_Cpp", (DL_FUNC)_LambertW_W_delta_Cpp_try);
    R_RegisterCCallable("LambertW", "_LambertW_W_delta_alpha_Cpp", (DL_FUNC)_LambertW_W_delta_alpha_Cpp_try);
    R_RegisterCCallable("LambertW", "_LambertW_W_gamma_Cpp", (DL_FUNC)_LambertW_W_gamma_Cpp_try);
    R_RegisterCCallable("LambertW", "_LambertW_RcppExport_validate", (DL_FUNC)_LambertW_RcppExport_validate);
}
  • commenting out
## # Register entry points for exported C++ functions
## methods::setLoadAction(function(ns) {
##     .Call('_LambertW_RcppExport_registerCCallable', PACKAGE = 'LambertW')
## })

While this fixed it too, it was a bit hacky since roxygenize / devtools:build overwrites the RccpExports.cppfile -- so the fix must be done by hand again. Commenting out onload/onunload works now automatically w/o having to modify files by hand.

@gmgeorg gmgeorg closed this Jun 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.