Reputation: 11
I try to install GSL on Win10 with the the CodeBlocks IDE.
I downloaded the Complete package, except sources of 11 July 2006, from http://gnuwin32.sourceforge.net/packages/gsl.htm
I try a simple example with the following code
#include <stdio.h>
#include <stdlib.h>`
#include <gsl/gsl_sf_bessel.h>
int main(int argc, char* argv[])
{
printf("Hello world!\n");
double x = 5.0;
double y = gsl_sf_bessel_J0(x);
printf ("Besel test J0(%g) = %.18e\n", x, y);
return 0;
}
I put the search directory for the compiler D:\Windows\Sofwares\gsl-1.8\include
and D:\Windows\Sofwares\gsl-1.8\lib\libgsl.a
D:\Windows\Sofwares\gsl-1.8\lib\libgslcblas.a
in the linker settings.
When I try to buid, I get the error message undefined reference to `gsl_sf_bessel_J0'|
Upvotes: 1
Views: 955
Reputation: 931
The method I describe below is defined as "implicit linking of a dynamic library" (dll).
Step 1) Go to 'Project buid options' -> select 'Search directory' tab -> select 'Compiler' tab -> click on 'Add' button and browse for the GnuWin32\include
folder.
Step 2) Stay on the 'search directories' tab and select 'linker' -> click on 'Add' button and browse for the GnuWin32\lib
folder.
Step 3) Click on 'Linker settings' tab -> click on Add button and type the names of library files you need for using GSL.
The library files must be written without the 'lib' prefix and without the '.a' suffix.
Step 4) Go to the GnuWin32\bin
directory -> copy the dll files (libgsl.dll
and libgslcblas.dll
) and paste to the folder containing your CodeBlock project file.
Paste the two dll files again into the bin/Debug
and bin/Release
directories, where you will find the executable file of your program.
Step 5) Write your own program, compile and start.
Now everything should work
I tested the program on an old version of Windows, but the procedure is the same.
Upvotes: 1