[Rcpp-devel] How to link a .lib file in a rcpp-package in a Windows environment?

Bernhard Pollner bernhard at bpollner.net
Tue Apr 26 17:55:31 CEST 2011


Hi Dirk,


Am 25.04.2011 um 04:54 schrieb Dirk Eddelbuettel:

> 
> You need to include headers for R too, e.g. 
> 
>  #include <R.h>
>  #include <Rdefines.h>
> 
> and maybe 
> 
>  #include <Rinternals.h>

That worked, everything runs smoothly then. :-)

> 
> | .... now what would be the line I would have to add to Makevars.win, or how do I have to modify the PKG_LIBS Line in order to incorporate "Plastic.lib"?
> 
> You probably want to look at a few packages using external libraries; there
> are a few that use the GSL.  One of them is mvabund which also uses Rcpp. It
> has 
> 
> ## This assumes that the LIB_GSL variable points to working GSL libraries
> ## It also assume that we can call Rscript to ask Rcpp about its locations
> PKG_CPPFLAGS=-std=c++0x -I$(LIB_GSL)/include
> PKG_LIBS=-L$(LIB_GSL)/lib -lgsl -lgslcblas $(shell $(R_HOME)/bin/Rscript.exe -e "Rcpp:::LdFlags()")
> 
> but understand that the environment variable use here is 'just for CRAN' and
> you do not have to worry about it.
> 
> You do need to understand what these two lines do though, which is why I
> recommended that you start with something simple.

:-) Success!!
I studied, found out what most of that means, and -- voila --  in the end the (very simple!!  :-)) )  working version of Makevars.win is like that:

PKG_LIBS = Plastic.lib $(shell "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" -e "Rcpp:::LdFlags()")
with Plastic.lib, which resides directly in src, being the library I wanted to link against.

It works, I can invoke the first simple functions from within R, I can enumerate the connected devices, clear the list and give back build-numbers and the like.

(But I fear the next questions are already forming on the horizon.....    :-(   )

Thank you very much for your help here,
with kind regards,
Bernhard Pollner





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


More information about the Rcpp-devel mailing list