Menu

problem about GSL

Help
2005-07-05
2012-07-26
  • Nobody/Anonymous

    The following sample code cutted form the GSL user's manual:

    include <stdio.h>

    include <gsl/gsl_rng.h>

    include <gsl/gsl_randist.h>

    int
    main (void)
    {
    const gsl_rng_type T;
    gsl_rng
    r;

    int i, n = 10;
    double mu = 3.0;

    / create a generator chosen by the
    environment variable GSL_RNG_TYPE
    /

    //gsl_rng_env_setup();

    //T = gsl_rng_default;
    r = gsl_rng_alloc (T);

    / print n random variates chosen from
    the poisson distribution with mean
    parameter mu
    /

    for (i = 0; i < n; i++)
    {
    unsigned int k = gsl_ran_poisson (r, mu);
    printf (" %u", k);
    }

    printf ("\n");
    return 0;
    }
    =========
    First I compile the programs with GSL statically and it runs correctlly.Then I try to compile the code with GSL dynamically, the compilation is successful, but when I run the program I get a runtime error (a dialog window shows that something wrong with libgsl.dll). Can someone tell me what's the problem in running the sample code with dynamically linking?

    ps. I compile the code by Dev-C++, under Windows XP

     
    • Nobody/Anonymous

      Hi

      I am having similar problems - how did you manage to get Dec C++ to compile statically so that GSL worked properly?

      Many thanks.

       
    • Nobody/Anonymous

      I too have this problem. If anyone knows of a solution please post. thank you.

       
      • leporello

        leporello - 2006-05-03

        Did someone solve this problem ?
        I'm using gsl with visual c++, everithing
        works, but when I run the program, it stops at

        r = gsl_rng_alloc (T);

        The error message is:

        Access violation reading location

         
    • Nobody/Anonymous

      To be more specific, the error occurs after this line:

      r = gsl_rng_alloc (T);

      Some kind of access violation error with libgsl.dll.

       
    • Nobody/Anonymous

      I have the exact problem as well and do not know how
      to fix it.

       
      • GnuWin

        GnuWin - 2006-02-23

        Did you compile with the define -DGSL_DLL ?

         
    • Jerry S.

      Jerry S. - 2006-05-04

      Using the gsl 1.6 dll and VC, one needs to define both WIN32 and GSL_DLL in order for the dll functions to be properly imported. Please make sure you're compiling with both /DWIN32 and /DGSL_DLL. If you are and you still get an access violation, please continue the thread.

      Jerry

       
  • Julia

    Julia - 2011-06-09

    Hi!

    I have a similar problem, my program compiled, linked successfully, but have a
    run problem:

    Unhandled exception : Access violation writing location.

    I have GnuWin32 gsl version 1.8, and Microsoft Visual C++ .NET, and I define
    the GSL_DLL in the Preprocessor Definitions, WIN32 defined too.

    I tried the solutions to similar problems, as copying the dll's to the local
    library with no success.

    Thanks you.

    Julia

    The code:

    include <gsl gsl_matrix.h="">

    int main (void){

    gsl_matrix * m = gsl_matrix_alloc (10, 3);

    gsl_matrix_free (m);

    return 0;

    }

     
  • Allan

    Allan - 2011-06-09

    On Windows XP systems when you link to a .dll you usually use an import
    library. I don't know anything about Dev C++ or what compiler it uses. Your
    import library could be called libgsl-dll.a' or it could belibgsl.lib' (or
    some variation of the preceding). You don't say how you link to the .dll in
    your post.

     
  • Jay Satiro

    Jay Satiro - 2011-06-21

    There are a few issues here, but the bottom line is when you are using GSL in
    a Visual Studio project you should link to GSL DLLs built with that same
    version of Visual Studio. You also want the includes which are different for
    Visual Studio. Also you should define GSL_DLL and I think CBLAS_DLL. Check out
    this webpage:

    The GNU Scientific Library (v1.15) for Visual Studio 2010

    http://gladman.plushost.co.uk/oldsite/computing/gnu_scientific_library.php

    Download that and follow the directions. There are a few problems when
    compiling in Debug mode so choose Release. I've already built it and I'll put
    it up in a few days in the tests folder.

     
  • Jay Satiro

    Jay Satiro - 2011-06-24

    dlls built for mingw and visual studio 2010 sp1 versions here:

    https://sourceforge.net/projects/getgnuwin32/files/getgnuwin32/test%20builds/

    GSL_1.15_binaries_and_devel__MINGW_ONLY.zip

    GSL_1.15_binaries_and_devel__VS_ONLY.zip

     
  • deathangelix

    deathangelix - 2012-05-31

    Hi raysatiro,

    I try your solution but was reported:

    error LNK1107: file broken: cannot read at 0x2A8 .... gsl.dll .....

    Do you have any idea?