[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 04:32:59 CEST 2011


Hi Dirk,

thank you for your answer.

I tried to write a very simple, pure package (without Rcpp), with the C-File named "ROnlyTest", where I put the code like suggested by you.

The Makevars.win contains now only: (*)
PKG_CPPFLAGS=-I.
PKG_LIBS=Plastic.lib

Unfortunetely, I can not compile (fail at "Rcmd check ROnlyTest") --- and I get the following error-message:
	ROnlyTest.cpp:3:1: error: 'SEXP' does not name a type

When I then write a "void" before the "SEXP", I get the error:
expected initializer before 'simpleText'
I am sure it is quite trivial, but I just do not know what to write as an "initializer".... , or to do this line just right.

But, apart from that, when the only thing I write into the C-File is:
	#include "PlasticHeader.h"
	int x = CallAFunctionFromPlasticDotLib();
then Rcmd check runs through nice, and I can build and install this package. Does that mean that the linking of Plastic.lib from above (*) was succesful?

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"?


Thanks a lot,
Bernhard




> 
> 
> A really simple (untested) one would be something like
> 
> 
> #include "whicheverHeaderYouNeed.h"   // adapt to what Plastic needs
> 
> SEXP simpleText(void) {		      // no arguments
> 
>   Rprintf("hello world--before call\n");
> 
>   // set up arguments as needed
>   someCallFromYourLibrarry(someArgs);     
> 
>   Rprintf("hello world--after call\n");
> 
>   return R_NilValue;		      // because of the SEXP return value
> }
> 
> 
> See how you far you get with this...



More information about the Rcpp-devel mailing list