[Rcpp-devel] Boot function for Module when compiling for WIN32 is not exported to DLL
Dirk Eddelbuettel
edd at debian.org
Thu Dec 20 20:26:21 CET 2012
Hi Volker,
On 20 December 2012 at 19:19, "Volker Steiß" wrote:
| 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.
I can't make any statements about Wine. What we release is targeted for
normal Windows use and deployment with the normal tools.
I know of the cross-compiler tool chain (cf old R/News article co-written by
Tony Rossini) but I haven't used that in years and I think we simply declare
that as unsupported. You're on your own there.
| 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,
Very, very, very early versions had it. We then removed it as the _normal
Windows use via Rtools and Mingw_ gets by without it. So the #define for
RcppExport no longer has it, and many example where written simply as the
underlying extern "C" SEXP foo()....
| 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.
Cygwin is _definitely_ not supported.
I'd urge you to consider the standard Windows toolchain. You can even have
the Uni Dortmund hosted win-builder.r-project.org create the package for you;
hit its top-level URL and read the docs. Easy as pie, not setup for you and
our users still get (working!!) Windows binaries.
If you still need a different toolchain (and there may always be reasons for
one) you probably have to lead setup and testing for it. We aim to cover
what CRAN covers.
Hope this helps, Dirk
|
| Best regards
| Volker
|
|
|
| ----------------------------------------------------------------------
| >From ce4f7c1347cbd776b5d76858251dc3f2a87e7715 Mon Sep 17 00:00:00 2001
| From: Volker Steiß <volker.steiss at mni.thm.de>
| Date: Thu, 20 Dec 2012 11:51:06 +0100
| Subject: [PATCH] Export boot function for Module when compiling for WIN32.
| To: rcpp-devel at lists.r-forge.r-project.org
|
| - Using LibExport definition of R to export boot function _rcpp_module_boot_*
| to add __declspec(dllexport) for modules when compiling for WIN32 but not in
| CYGWIN.
| ---
| inst/include/Rcpp/Module.h | 2 +-
| 1 file changed, 1 insertion(+), 1 deletion(-)
|
| diff --git a/inst/include/Rcpp/Module.h b/inst/include/Rcpp/Module.h
| index ed922ce..904729b 100644
| --- a/inst/include/Rcpp/Module.h
| +++ b/inst/include/Rcpp/Module.h
| @@ -396,7 +396,7 @@ namespace Rcpp{
| #define RCPP_MODULE(name) \
| void _rcpp_module_##name##_init() ; \
| static Rcpp::Module _rcpp_module_##name( # name ) ; \
| - extern "C" SEXP _rcpp_module_boot_##name(){ \
| + extern "C" LibExport SEXP _rcpp_module_boot_##name(){ \
| ::setCurrentScope( & _rcpp_module_##name ) ; \
| _rcpp_module_##name##_init( ) ; \
| Rcpp::XPtr<Rcpp::Module> mod_xp(& _rcpp_module_##name , false); \
| --
| 1.7.9.5
|
| ----------------------------------------------------------------------
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
--
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
More information about the Rcpp-devel
mailing list