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
>From ce4f7c1347cbd776b5d76858251dc3f2a87e7715 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Volker=20Stei=C3=9F?= <[email protected]>
Date: Thu, 20 Dec 2012 11:51:06 +0100
Subject: [PATCH] Export boot function for Module when compiling for WIN32.
To: [email protected]
- 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
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel