António Rocha wrote:

> 
> Hi Glynn
> I think you do magic because I've tried a couple of times without 
> success and, right after I received your email I suceed compiling 
> dllmain.c. :)
> 
> About OBJDIR, At GRASS.make it's defined as you said:
> OBJDIR        = OBJ.$(ARCH)
> So no problem with this
> 
> Now, with compiling i.pr:
> I'm getting the following error (see below). it has something to do with 
> drand48. drand48 is a function mentioned in line 42 of bootstrap.c of 
> PRLIB folder.
> Does this function ring a bell? I have searched and there is no file 
> with that name in GRASS6 folder neither sourcecode or snapshot.

drand48() is a standard function on most Unix systems, but Windows
doesn't have it. If you look in include/config.h, you'll see:

        /* define if drand48() exists */
        /* #undef HAVE_DRAND48 */

It's easy enough to simulate it; the following is adapted from
raster/r.mapcalc/xrand.c:

        #if !defined(HAVE_DRAND48)
        #define drand48() ((double)rand()/((double)RAND_MAX + 1))
        #endif

The above should either be added to the top of i.pr/PRLIB/svm.c (if
that is the only file which needs it), or added to
i.pr/include/global.h (if several files need it).

OTOH, if the algorithm requires a high level of randomness, it might
need something better; Windows' rand() function only returns 15 bits
of data, which may not be enough.

A more accurate solution is:

        #if !defined (HAVE_DRAND48)
        #if defined(HAVE_LONG_LONG_INT)
        static unsigned long long state;
        
        /* see:
         * http://www.opengroup.org/onlinepubs/9699919799/functions/drand48.html
         */
        static unsigned long long next(void) {
                state = (0x5DEECE66DULL * state + 0xB) & 0xFFFFFFFFFFFFULL;
                return state;
        }
        
        double drand48(void) {
                return (double) next() / 0x1000000000000ULL;
        }
        #else
        /* no drand48(), no "long long" type, don't know whether "long"
         * is 64-bit and can't be bothered implementing multi-word
         * arithmetic, so we'll have to live with this crude approximation
         */
        #define drand48() ((double)rand()/((double)RAND_MAX + 1))
        #endif
        #endif

-- 
Glynn Clements <gl...@gclements.plus.com>
_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

Reply via email to