[Rcpp-devel] Some suggestions

Dominick Samperi djsamperi at gmail.com
Sat Jul 10 03:25:53 CEST 2010

Here are some suggested changes (under Windows) that will not affect
existing users but may help to prevent clashes with other packages in the

1. RcppExport is not defined the way it used to be under Windows, but
there are situations where the old definition is convenient. For example,
it reduces the size of package DLL's the are not intended to be used
by other packages (the most common situation).

A simple work-around is to define RcppExportFinal the old way, using
something like:

#if defined(mingw32) || defined(WIN32)
#define RcppExportFinal extern "C" __declspec(dllexport)
#define RcppExportFinal extern "C"

Let me know if/when you implement this so it does not clash with
the same definition in my package.

2. The current default behavior where a static lib is used
(libRcpp.a) is probably the most convenient and portable, but
there are situations where it is useful to link directly to Rcpp.dll.

To facilitate this one of the path functions in RcppLdpath.R
needs to be changed slightly for the case static=FALSE:

RcppLdFlags <- function(static=staticLinking()) {
    rcppdir <- RcppLdPath()
    if (static) {                               # static is default on
Windows and OS X
        flags <- paste(rcppdir, "/libRcpp.a", sep="")
        #if (.Platform$OS.type=="windows") {
        #    flags <- shQuote(flags)
    } else {                    # else for dynamic linking
        flags <- paste("-L", rcppdir, " -lRcpp", sep="") # baseline setting
        if((.Platform$OS.type == "windows")) {
          flags <- paste(rcppdir, "s/Rcpp.dll",sep="")
        if ((.Platform$OS.type == "unix") &&    # on Linux, we can use rpath
to encode path
            (length(grep("^linux",R.version$os)))) {
            flags <- paste(flags, " -Wl,-rpath,", rcppdir, sep="")

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20100709/47dd4092/attachment.htm>

More information about the Rcpp-devel mailing list