Using GSL with cygwin g ++

trying to get the Gnu Science Library (gsl) to work in cygwin g ++.

Cygwin is installed and updated by all default parameters and includes gsl: runtime, gsl-apps and gsl-doc. I am trying the example program provided on the gsl website:

http://www.gnu.org/software/gsl/manual/html_node/An-Example-Program.html

turn on

#include <gsl/gsl_sf_bessel.h> int main (void) { double x = 5.0; double y = gsl_sf_bessel_J0 (x); printf ("J0(%g) = %.18e\n", x, y); return 0; } 

Can anyone be so kind as to give me a version of the above program that really works with g ++? The header file was not found anywhere with this default setting. How to access dll?

I also tried to install the non-standard “gsd-devel” (development tools) which gives me access to the header file, but when I compile, I get the “Undefined” link to “gsl__sf_bessel_J0”, even though the header file is found.

Any help is much appreciated!

+4
source share
1 answer

I am new to CygWin and GSL, and after some research, I believe that the answer is that the required libraries are not related. There is a smart little tool that comes with GSL called gsl-config . You can use this to get information about links to libraries. So in your case the code is:

 #include <gsl/gsl_sf_bessel.h> #include <stdio.h> int main (void) { double x = 5.0; double y = gsl_sf_bessel_J0 (x); printf ("J0(%g) = %.18e\n", x, y); return 0; } 
can be compiled using g++ bessel.cpp -lm -lgsl -o bessel.out -L/usr/bin where the -lm -lgsl -L/usr/bin bit is the output of typing gsl-config --lib-without-cblas . Test using ./bessel.out .

Hope this helps, T

+4
source

All Articles