[Rcpp-devel] Boot function for Module when compiling for WIN32 is not exported to DLL

"Volker Steiß" volker.steiss at mni.thm.de
Thu Dec 20 19:19:46 CET 2012


Hello,

first of all: Thanks for creating Rcpp. It is great in interconnecting R
and C++.

I am currently working on a project written in C++ using the Boost library
and Bjam as build system. C++ code is called from R using Rcpp. The
RCPP_MODULE directive is used to export some classes.
Development is taking place on GNU/Linux but the program should run on
Win, too. Therefore I created a cross-compilation chain using MinGW and
Wine.
At the moment only 32-bit DLLs are generated.

When creating the shared object for GNU/Linux everything works fine. Also
the cross-compilation chain works; random Win 32-bit binaries are created
successfully.

The cross-compilation chain consists of:
 - Ubuntu 11.10
 - Wine 1.3.28
 - MinGW with g++ in version 4.6.1
 - Boost 1.51
 - …
 - Rcpp in version 10.1 (also used older versions e. g. 0.9.15)




The Problem:
When compiling the DLL no symbols related to the module are exported.
After some investigation I figured out __declspec(dllexport) is missing,
to mark the functions to be packed into the DLL.
When loading the R package containing the Rcpp modules this results in the
error message (<name> and <pkgname> are two strings I replaced):
   Error in Module(module, mustStart = TRUE) :
      Failed to initialize module pointer: Error in
FUN("_rcpp_module_boot_<name>"[[1L]], ...): no such symbol
_rcpp_module_boot_<name> in package
Z:/home/user/opt/R/library/<pkgname>/libs/i386/<name>.dll

The Fix:
Add LibExtern to the Module's boot function. A patch is attached.


I still wonder if I made any mistake or if this problem does not occur
using Cygwin to compile on Win directly.


Best regards
  Volker


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Export-boot-function-for-Module-when-compiling-for-W.patch
Type: text/x-patch
Size: 1374 bytes
Desc: not available
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20121220/73972996/attachment.bin>


More information about the Rcpp-devel mailing list