Menu

runtime error using GSL Vista

2008-08-28
2012-09-26
  • Jason Slemons

    Jason Slemons - 2008-08-28

    Im running Vista(32 bit) SP1 and Dev 4.9.9.2 and I just got the GSL package(which until now works super)

    the following program compiles and runs fine:
    #include <stdio.h>
    #include <gsl/gsl_rng.h>
    int main (void)
    {
    const gsl_rng_type * T;
    gsl_rng * r;
    gsl_rng_env_setup();
    T = gsl_rng_default;
    \ r = gsl_rng_alloc (T);
    gsl_rng_free (r);
    return 0;
    }
    but if i take away the comments compile and run again, it doesnt run. both compile logs look fine:
    Compiler: Default compiler
    Executing g++.exe...
    g++.exe "C:\Users\Jason Slemons\Documents\CPP\randomgen.cpp" -o "C:\Users\Jason Slemons\Documents\CPP\randomgen.exe" -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" -L/C/Dev-cpp/lib -lgsl -lgslcblas -lm
    Execution terminated
    Compilation successful

    The actual runtime error i get is the a dos window with another vista window over top with the message "A problem cause the program to stop working correctly. Windows will close the program and notify you if a solution is available."

    This whole process (compile, run)works fine using the command line on Red hat. So its something to do with Dev and/or windows. This example program is given in the GSL doccumentation section 17.13.

     
    • cpns

      cpns - 2008-08-28

      > So its something to do with Dev and/or windows.

      Of all the conclusions you might have come to, that is the least likely. Dev-C++ is not a compiler, it is an IDE. The compiler it uses is GCC - just like Red Hat.

      I wonder if gsl_rng_default is valid, it is determined by the GSL_RNG_TYPE environment variable if you have defined one, if not it should default to mt19937. However the documentation does not say what happens if you set it to something invalid. I imagine it should be ignored, but nonetheless, try setting a explicit generator rather than relying on the default. If that works, you might try setting the environment variable, and trying gsl_rng_default again.

      Personally I'd use an explicit generator in any case - why would the system global environment know what your application needed!?

      Note that with the gsl_rng_alloc call commented, gsl_rng_free gets an uninitialized pointer, so if that runs without complaint, it is more by luck than judgement!

      Clifford

       
      • Jason Slemons

        Jason Slemons - 2008-08-30

        Thanks for your reply. I get that I need a specific rng type nstead of the default. so i tried the code below. Oh and, i also went to the dos prompt and "set GSL_RNG_SEED=123" and "set GSL_RNG_TYPE="taus"". I then executed it from the dos prompt(fair enough; is an Dev++ is an IDE). Same runtime problem as I described before. It compiles fine though. It may be something silly.

         #include &lt;stdio.h&gt;
         #include &lt;gsl/gsl_rng.h&gt;
        
         int
         main (void)
         {
        
           gsl_rng * r;
           const gsl_rng_type * T = gsl_rng_taus;
           r = gsl_rng_alloc (T);
           gsl_rng_free (r);
        
           return 0;
         }
        
         
    • cpns

      cpns - 2008-08-28

      ... A few weeks ago this came up: http://sourceforge.net/forum/forum.php?thread_id=2092060&forum_id=48211

      It is not directly related to your problem, but it does have information in the answers that may useful to you.

      Clifford

       

Log in to post a comment.