[Rcpp-devel] Using GSL in R with Rcpp

Dirk Eddelbuettel edd at debian.org
Wed Apr 2 13:26:11 CEST 2014


On 2 April 2014 at 11:14, Petre Caraiani wrote:
| Hello!
| I am trying to run the example here:
| http://gallery.rcpp.org/articles/gsl-colnorm-example/
| 
| I get the following error:
| 
| g++ -m64 -I"C:/R/R-30~1.3/include" -DNDEBUG -IC:/GSl-1.16/include     -I"E:
| /Users/peter/Documents/R/win-library/3.0/Rcpp/include" -I"E:/Users/peter/
| Documents/R/win-library/3.0/RcppGSL/include"  -I"d:/RCompile/CRANpkg/
| extralibs64/local/include"     -O2 -Wall  -mtune=core2 -c test.cpp -o
| test.o

1) Your email does not state how you invoke g++ (or R, which invokes it for you)

2) Your email is not complete as it has no reproducible code

3) Your email refers to a working examples _which still works_ (see below)

4) All you need to know is spelled out in the Rcpp documentation. I am not
going to repeat it here.  See eg the two chapters on 'compiler etc setup' and
RcppGSL in my Rcpp book.

Dirk


edd at max:~ cd /tmp/
edd at max:/tmp$ cp -vax ~/git/rcpp-gallery/src/*colnorm* .
‘/home/edd/git/rcpp-gallery/src/2012-12-22-gsl-colnorm-example.cpp’ -> ‘./2012-12-22-gsl-colnorm-example.cpp’
edd at max:/tmp$ Rscript -e 'library(Rcpp); sourceCpp("2012-12-22-gsl-colnorm-example.cpp")'

R> M <- outer(sin(0:9), rep(1, 10), "*") + outer(rep(1, 
+     10), cos(0:9), "*")

R> colNorm(M)
 [1] 4.31461 3.12050 2.19316 3.26114 2.53416 2.57281 4.20469 3.65202 2.08524 3.07313

R> apply(M, 2, function(x) sqrt(sum(x^2)))
 [1] 4.31461 3.12050 2.19316 3.26114 2.53416 2.57281 4.20469 3.65202 2.08524 3.07313
edd at max:/tmp$ 

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list