-lgsl -lgslcblas fatal error no such file or directory

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

-lgsl -lgslcblas fatal error no such file or directory


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.

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 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.