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

Dirk Eddelbuettel edd at debian.org
Tue Apr 26 18:24:02 CEST 2011


Hi Bernhard,

On 26 April 2011 at 17:55, Bernhard Pollner wrote:
| 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. :-)

Yup, good!

|     ## 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()")

Perfect!!  No transformation needed for Plastic.lib, ie no export table
business and all that as discussed in the MinGW FAQ?

In that case maybe I should mention this use case in the Rcpp-FAQ....

| 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..... :-( )

We'll take it one step at a time. Just how you were able to decompose this
problem into manageable chunks, we'll just do the same with the next apparent roadblock.

| Thank you very much for your help here,

Always a pleasure.

Cheers, Dirk


-- 
Gauss once played himself in a zero-sum game and won $50.
                      -- #11 at http://www.gaussfacts.com


More information about the Rcpp-devel mailing list