I downloaded, compiled, and installed the GNU Scientific Library (gsl) on my mac, which locates /usr/local/include/gsl as default.
To test it, I have tried to compile and execute the example C program (found from gsl document).
#include <stdio.h>
#include <gsl/gsl_statistics.h>
int
main(void)
{
double data[5] = {17.2, 18.1, 16.5, 18.3, 12.6};
double mean, variance, largest, smallest;
mean = gsl_stats_mean(data, 1, 5);
variance = gsl_stats_variance(data, 1, 5);
largest = gsl_stats_max(data, 1, 5);
smallest = gsl_stats_min(data, 1, 5);
printf ("The dataset is %g, %g, %g, %g, %g\n",
开发者_如何学C data[0], data[1], data[2], data[3], data[4]);
printf ("The sample mean is %g\n", mean);
printf ("The estimated variance is %g\n", variance);
printf ("The largest value is %g\n", largest);
printf ("The smallest value is %g\n", smallest);
return 0;
}
To compile it,
$ gcc -I /usr/local/include -c example.c
$ ls
example.c example.o
And, to execute it,
$ ./example.o
-bash: ./example.o: Permission denied
What's happening? Who can run it other than me?
example.o
is an object file, not an executable.
According to the documentation (info gsl-ref
to read it), this should work (or at least it's close).
$ gcc -Wall -I/usr/local/include -c example.c
$ gcc -L/usr/local/lib example.o -lgsl -lgslcblas -lm -o example
$ ./example
精彩评论