[Rcpp-devel] How to link a .lib file in a rcpp-package in a Windows environment?
Bernhard Pollner
bernhard at bpollner.net
Mon Apr 25 12:35:08 CEST 2011
Hello 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>
I did that, so, the "final" C document looks like:
> | > #include "plastic.h" // adapt to what Plastic needs
> #include <R.h>
> #include <Rdefines.h>
> #include <Rinternals.h>
> > SEXP simpleText(void) { // no arguments
> | >
> | > Rprintf("hello world--before call\n");
> | >
> | > int x = aCallFromPlasticLibrary();
> | >
> | > Rprintf("hello world--after call\n");
> | >
> | > return R_NilValue
> | > }
With that it works, Rcmd check runs through nicely, I can install the package. I do not know how to load and run "simpleText()", though, but that probably does not matter. So I assume that, without using Rcpp and having only
PKG_CPPFLAGS=-I.
PKG_LIBS=PsyREG.lib
in the Makevars.win, things are ok.
> | In the latter case, 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()")
>
Ok, I am working on that now, try to understand what it means and modify the lines to my own needs.
I´let you know how things are going here soon...
Meanwhile thanks a lot,
Bernhard
> 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.
>
> Hope this helps, Dirk
>
> |
More information about the Rcpp-devel
mailing list