Problem with GNU Scientific Library Example

Hi,

I am using exact the code showed in "2.1 An Example Program" from "http://www.gnu.org/software/gsl/manual/html_node/An-Example-Program.html"

1
2
3
4
5
6
7
8
9
10
11
     #include <stdio.h>
     #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;
     }


And I am getting this error message:

1
2
3
4
5
6
7
8
build/Debug/GNU-Linux-x86/main.o: In function `main':
/home/cristiano/NetBeansProjects/gsl_test/main.cpp:13: undefined reference to `gsl_sf_bessel_J0'
collect2: ld returned 1 exit status
gmake[2]: *** [dist/Debug/GNU-Linux-x86/gsl_test] Error 1
gmake[1]: *** [.build-conf] Error 2
gmake: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 265ms)


What am I missing?
Last edited on
Looks like either you haven't got the library properly installed, or for some other reason your compiler doesn't know where to find it. Do you link to the library when you compile?
Did you tell the compiler/linker that you want to link to that library?
Topic archived. No new replies allowed.