Author Topic: Installing GSL to code blocks on windows  (Read 14775 times)

Offline Taich

  • Single posting newcomer
  • *
  • Posts: 3
Installing GSL to code blocks on windows
« on: September 24, 2010, 06:44:04 pm »
Hello there. I've been looking through some of the post on these forums and found them to be quite useful, unfortunatly, I have come to a point where I no longer understand what is going wrong and what I am supposed to do, thats why I'm submitting my problem to you in the hopes that someone can help me.

Basically I installed Code Blocks on my Computer and found it to be really, reeaally good! (the computers at uni use quincy). I want to use the GSL libraries to solve eigenvalue problems and to generate random numbers from the normal distribution. I could code these things manually but decided it would be much more efficient to have a large library of functions I could use that have functions outside the ones I am immediatly interested in, just for future references.

Anyway, I had been reading this thread: http://forums.codeblocks.org/index.php?topic=9485.0

The code I have been trying to run is the GSL eigenvalue example

Code
     #include <iostream>
     #include <gsl/gsl_math.h>
     #include <gsl/gsl_eigen.h>
     using namespace std;

     int
     main (void)
     {
       double data[] = { 1.0  , 1/2.0, 1/3.0, 1/4.0,
                         1/2.0, 1/3.0, 1/4.0, 1/5.0,
                         1/3.0, 1/4.0, 1/5.0, 1/6.0,
                         1/4.0, 1/5.0, 1/6.0, 1/7.0 };

       gsl_matrix_view m
         = gsl_matrix_view_array (data, 4, 4);

       gsl_vector *eval = gsl_vector_alloc (4);
       gsl_matrix *evec = gsl_matrix_alloc (4, 4);

       gsl_eigen_symmv_workspace * w =
         gsl_eigen_symmv_alloc (4);

       gsl_eigen_symmv (&m.matrix, eval, evec, w);

       gsl_eigen_symmv_free (w);

       gsl_eigen_symmv_sort (eval, evec,
                             GSL_EIGEN_SORT_ABS_ASC);

       {
         int i;

         for (i = 0; i < 4; i++)
           {
             double eval_i
                = gsl_vector_get (eval, i);
             gsl_vector_view evec_i
                = gsl_matrix_column (evec, i);

             printf ("eigenvalue = %g\n", eval_i);
             printf ("eigenvector = \n");
             gsl_vector_fprintf (stdout,
                                 &evec_i.vector, "%g");
           }
       }

       gsl_vector_free (eval);
       gsl_matrix_free (evec);

       return 0;
     }


and I get the following error:

error: gsl/gsl_math.h: no such file or directory
error: gsl/gsl_eigen.h: no such file or directory
then a list of 25 errors related to not having found the header file.

I had unzipped the GNUWin32 library from sourceforge and I think i linked the libraries to the project but I don't know how to tell the Program where to look for the header files.

I feel that I am probably making some kind of rookie error at the moment, because to be honest, I am a rookie at this.
One thing that confused me was the zip file only had headers in the files, there was no C code, I assume that all the actual C program code is held in the .a files

Any help with this would be much appretiated, if you need more info just say so, I'm not entirely sure what i need to tell you to help you.

thanks :)

Offline reckless

  • Regular
  • ***
  • Posts: 338
Re: Installing GSL to code blocks on windows
« Reply #1 on: September 24, 2010, 07:11:55 pm »
rightclick the project and select build options then open the tab search directories, can add include and libs in non standard directories to ld'd search path from there.

this is however on a project by project basis if you allways want to include these directories your better of adding them globally.

Offline Taich

  • Single posting newcomer
  • *
  • Posts: 3
Re: Installing GSL to code blocks on windows
« Reply #2 on: September 25, 2010, 11:47:47 am »
ok, I have gone: right click project -> build options -> Search Directories tab

then under compiler, append target options to project options, I have added the file which contains all the Header files from the GSL library
under linker I have added the file that contains the Libraries from the GSL library.

I have also gone to settings -> compiler and debugger -> Search Directories and done the same thing for the linker and compiler

It is still giving me the same error

I havent Manually added the header files to the project. when I did that, it popped up telling me it couldnt find every other header file needed to make the code run.


Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Installing GSL to code blocks on windows
« Reply #3 on: September 25, 2010, 07:20:11 pm »
You need to add the path the contains the sub-folder "gsl".

Turn on Full Compiler Logging; if you do not know how read the Wiki FAQ.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Taich

  • Single posting newcomer
  • *
  • Posts: 3
Re: Installing GSL to code blocks on windows
« Reply #4 on: September 25, 2010, 07:52:01 pm »
Brilliant! I took your advice stahta and it compiles and spits out what looks like the answer. Cruel experience has taught me that if the program spits out numbers that look like it is the answer, they arent necessarily the one you were after. I'll do some testing but it appears to be working now, thank you very much for your input, I appretiate the help!