trying to learn GSL (GNU Scientific Library)on mac OS X (El Capitan) following this tutorial (which is BTW the third result on my google search!).
- I installed GSL using homebrew
- following the comments on this post I changed flags from -lgslblasnative to -lgslcblas.
now it compiles but I get a Segmentation fault: 11 error while running the program. There are a number of possibilties. first is the stackoverflow, which is very unlikly with such a samll program. second there is an array somewhere and the program is trying to write on the memory which has not allocated. or there is something wrong with GSL. I would appreciate if you could help me.
edit 1: this is the code I'm trying to run
#include <stdio.h>
#include <gsl_rng.h>
#include <gsl_randist.h>
int main (int argc, char *argv[])
{
/* set up GSL RNG */
gsl_rng *r = gsl_rng_alloc(gsl_rng_mt19937);
/* end of GSL setup */
int i,n;
double gauss,gamma;
n=atoi(argv[1]);
for (i=0;i<n;i++)
{
gauss=gsl_ran_gaussian(r,2.0);
gamma=gsl_ran_gamma(r,2.0,3.0);
printf("%2.4f %2.4f\n", gauss,gamma);
}
return(0);
}