[Rd] -lgsl -lgslcblas fatal error no such file or directory

kevinpw p.kevin.white at gmail.com
Sat Jun 9 23:18:08 CEST 2012


Novice programmer.

I'm writing C source code and compiling it in as *.dll in the terminal by R
CMD SHLIB foo.c. It works, I'm on a 64 bits windows system. I have the
lastest R 2.15.0 and Rtools using the gcc 4.6.3 compiler.

However, that was a hello world run, and I installed GSL for the 64 bit
system for fast MCMC. The Rcpp package was easy to use, but I opted for a C
with GSL fashion because a MCMC simulation I'm attempting would have been
astronomically time consuming with the JAGS Sampler. A couple webpages
suggested the C/GSL might be optimal. 

My issue is that even though the R CMD SHLIB *c built the *dll for simple
examples, when I installed GSL for the (64 bit system), the R CMD -lgsl
-lgslcblas *c returns a fatal error: gsl/gsl_rng.h no such file or directory
exists. My paths are:

Does the order matter? I think Rtools needed to go first (in their order) in
the path list.

Files (x86)\MiKTeX 2.8\miktex\bin;C:\Program Files\Common Files\Microsoft
Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft
Files\SAS\SharedFiles(32)\Formats;C:\Program Files (x86)\Windows
Live\Shared;C:\Program Files

I also created two new variables in the system environmental variables list
GSL_LIB, value c:/R/GSL_test2/lib/
GSL_INC, value c:/R/GSL_test2/inc/

The source C code is

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>
#include <R.h>

void gibbsGSL(int *Np,int *thinp,int *seedp,double *xvec,double *yvec) {
    int i,j;
    int N=*Np,thin=*thinp,seed=*seedp;
    gsl_rng *r = gsl_rng_alloc(gsl_rng_mt19937);
    double x=0;
    double y=0;
    for (i=0;i<N;i++) {
        for (j=0;j<thin;j++) {
        xvec[i]=x; yvec[i]=y;

Any advice would be appreciated.

View this message in context: http://r.789695.n4.nabble.com/lgsl-lgslcblas-fatal-error-no-such-file-or-directory-tp4632908.html
Sent from the R devel mailing list archive at Nabble.com.

More information about the R-devel mailing list