Skip to content
Prev 30151 / 63424 Next

LinkingTo on Windows

On Tue, 7 Oct 2008, Thomas Baier wrote:

            
Have you read the documentation for 'LinkingTo'?  That is not what it is 
documented to do, and it does work on Windows (as documented).
Well, R_GetCCallable hides all these details for you.
Hmm, it has been addressed and there are working examples (on CRAN and 
BioC).  However, there is another approach possible on Windows _only_ that 
seems close to what you are asking for.

On Windows there are two issues, compilation and run-time.  The run-time 
issue is easy to solve using the Dllpath argument to library.dynam (and 
that is the bit that cannot be done portably across OSes).  The 
compilation-time issue can be addressed in many ways, but perhaps the 
simplest is to make in package rcom an import library for rscproxy.dll

The main problem with the CRAN version of rcom is that rproxy.h is 
missing.  If I copy that file from the 2.7.2 sources and alter 
rcom/src/Makevars to have

PKG_LIBS = -L. -lrscproxy $(ADD_LIBS) -lole32 -luuid -loleaut32 -lgdi32
DLLTOOLFLAGS=--as $(AS)

before: librscproxy.dll.a
librscproxy.dll.a: rscproxy.def

with

$ cat rcom/src/rscproxy.def
LIBRARY rscproxy.dll
EXPORTS
  ANSI2BSTR
  BDX2SEXP
  BDX2Variant at 8
  BSTR2ANSI
  R_Proxy_printf
  SEXP2BDX
  Variant2BDX at 20
  bdx_free at 4
  com_addObject
  com_createSEXP
  com_getHandle
  com_getOLECHAR
  com_getObject

this installs for me (and I always install to a non-default library).

I then removed the useDynLib call in NAMESPACE and added in .onLoad

     toRscproxy <- system.file("libs", package="rscproxy")
     library.dynam("rcom", pkg, lib, Dllpath=toRscproxy)

but I am not sure that is needed if rscproxy.dll is already loaded into 
the process.

An alternative is to run R at install time and ask it to print out 
system.file("libs", package="rscproxy"), in a similar way to finding the 
'LinkingTo' paths.