[R] R CMD -lgsl -lgslcblas *.c returns a fatal error: gsl/gsl_rng.h no such file or directory exists

kevinpw p.kevin.white at gmail.com
Sat Jun 16 13:29:00 CEST 2012


Hello, 

I tried this posted on the R devel subforum but no help so far. Maybe the
wider net will be fruitful. Probably a pretty simple issue.

The short story goes, I'm writing C source code and compiling it in as *.dll
in the windows terminal by R CMD SHLIB foo.c. It works, I'm on a 64-bit
system. I have the lastest R 2.15.0 and Rtools, and I am using the gcc 4.6.3
compiler.
 
However, the working program is a hello world run. Next, I installed GSL for
the 64-bit system for fast MCMC. I found the Rcpp package easy to use, but I
opted for calling C source code with the GSL random number generator because
a MCMC simulation I'm attempting takes weeks or months in my previous
attempts 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 the
simple example, when I installed GSL for the (64-bit system), the apparently
appropriate terminal command, R CMD -lgsl -lgslcblas *c, returns a fatal
error: gsl/gsl_rng.h no such file or directory exists. I understand the
issue may be with the way my windows paths are set up. My paths are:
 
PATH =
c:\R\Rtools\bin;c:\R\Rtools\gcc-4.6.3\bin;C:/R/R-2.15.0/bin/x64;C:\Program
Files (x86)\MiKTeX 2.8\miktex\bin;C:\Program Files\Common Files\Microsoft
Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft
Shared\Windows
Live;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program
Files\SAS\SharedFiles(32)\Formats;C:\Program Files (x86)\Windows
Live\Shared;C:\Program Files
(x86)\QuickTime\QTSystem\;C:\R\batchfiles_0.6-6;C:/R/GSL_test2/bin

I understand order matters for Rtools. They should go first in the path list
and have their own order. You'll notice I have the GSL path right on the end
of the list. Should it go somewhere else? In physical location or path
location? 
 
I also created the 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 failing C source 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); 
    gsl_rng_set(r,seed); 
    double x=0; 
    double y=0; 
    for (i=0;i<N;i++) { 
        for (j=0;j<thin;j++) { 
            x=gsl_ran_gamma(r,3.0,1.0/(y*y+4)); 
            y=1.0/(x+1)+gsl_ran_gaussian(r,1.0/sqrt(2*x+2)); 
        } 
        xvec[i]=x; yvec[i]=y; 
    } 
} 

Any advice would be appreciated. 



--
View this message in context: http://r.789695.n4.nabble.com/R-CMD-lgsl-lgslcblas-c-returns-a-fatal-error-gsl-gsl-rng-h-no-such-file-or-directory-exists-tp4633588.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list