Skip to content
Prev 1533 / 12125 Next

[R-pkg-devel] DllInfo & native routine registration

Hello R-package-devel,

I have just completed porting the MonetDBLite package to use registered native routines [1]. This worked fine except one minor issue: MonetDBLite (and I suppose other software) extensively uses dlsym to find its own internal functions. This used to rely on dlsym(dlopen(NULL, RTLD_NOW | RTLD_GLOBAL), ?some symbol?). However, in line with the new registration requirement, I changed this to dlopen from the specific .so file that contains my package C code. However, for this to work, I need a full path to the .so file in the installed R package. 

Now, I found that (conveniently), that path is contained in the DllInfo structure that is passed to the registration function. All is well if I just use that path. However, the DllInfo structure is opaque with a non-public definition in Rdynpriv.h. I think thats fine, but would it be possible to export a simple function like

void* R_get_dllinfo_path(DllInfo *dll) {
	return strdup(dll->path);
}

so one can pull the library path for dlopen() purposes?

Best and thanks,

Hannes

[1] https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Converting-a-package-to-use-registration