Dear Dirk, dear Ivan, thanks for your suggestions. I agree that R packages aren't meant to be build that way, and even though this is an academic project but since the source code wasn't written by me it is not my decision if, where and when to publish it openly. In any case, directly linking to a DLL seems quite unstable and I just came across the option to do a system call to an executable instead which appears to maybe be the most straight forward solution for me.
Thanks a lot for your time and effort. Best, Lisa On Sun, Jun 28, 2020 at 10:39 PM Ivan Krylov <krylov.r...@gmail.com> wrote: > On Sun, 28 Jun 2020 12:43:53 +0200 > Lisa GM <lisainconnecti...@gmail.com> wrote: > > > "sum_c" not resolved from current namespace (sum) > > As mentioned by Dirk Eddelbuettel, this is not the way R packages are > supposed to be built [*], but if you are absolutely positive you cannot > build the DLL from source together with the package or link your > package to externally installed DLL (as done by packages curl, rgdal, > and many others), it still seems to be possible. I have been able to > get a dummy package to work like this: > > .onLoad <- function(libname, pkgname) > library.dynam('dynl', pkgname, libname, TRUE) > > .onUnload <- function(libpath) > library.dynam.unload('dynl', libpath) > > do <- function() > .C('do_hello', x = as.integer(1L), y = as.numeric(2), PACKAGE = 'dynl') > > (Note the extra PACKAGE argument required in absence of native routine > registration or useDynLib(...) declarations in NAMESPACE) > > I placed the DLL itself in file.path('inst', 'libs', > paste0('dynl', .Platform$dynlib.ext)) under the package source > directory and made sure that it exports a C function > void do_hello(int * x, double * y). > > Needless to say, this goes against CRAN and Bioconductor policies. The > preferred approach is described in Writing R Extensions, section 1.2. > > -- > Best regards, > Ivan > > [*] See <https://cran.r-project.org/doc/manuals/R-exts.html> sections > 1.5.4 and 5.4 for preparing C functions to be called from an R package. > The Rcpp package does wrap all this in a very convenient way, see the > Rcpp.package.skeleton function. > [[alternative HTML version deleted]] ______________________________________________ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel