[R-pkg-devel] Error in inDL(x, as.logical(local), as.logical(now), ...) unable to load shared object

Dirk Eddelbuettel edd @end|ng |rom deb|@n@org
Thu Dec 23 15:34:30 CET 2021


On 23 December 2021 at 11:07, Tomas Kalibera wrote:
| You can have a look at CRAN package Rblpapi which is using an external DLL.

Yes with one big caveat: You have to make sure the library follows what is
the "hour-glass pattern": it needs to have an internal (the "narrow" part) C
library covering the wider underlying library and offered via a wider header.

Only C linkage works across different compiler families. You just cannot use
a Virtual C++-made Windows DLL from R's MinGW g++ compiler with C++.

But you can use C linkage.  So some libraries (such as the Bloomberg API used
in Rblpapi and the TileDB API used in the tiledb package (when not using a
local build) can use a library following the hourglass pattern:

 - "wide" bottom layer (may be C++ or C) with the core implementation
 
 - "narrow" C layer accessing the bottom and priving an API providing via C
   which profits from C's portable foreign function interface

 - "wide" layer on top via a header-only C++ file accesssing the C and
   which the C++ compiler optimizes away so that the C API is used for linking

Sounds complicated, but works great.

Good detail is in a hour-long but not-too-technical talk here

 https://www.youtube.com/watch?v=PVYdHDm0q6Y

and slides etc are here

 https://github.com/CppCon/CppCon2014/tree/master/Presentations/Hourglass%20Interfaces%20for%20C%2B%2B%20APIs

Dirk

-- 
https://dirk.eddelbuettel.com | @eddelbuettel | edd using debian.org



More information about the R-package-devel mailing list