Skip to content

MINGW build suggestions.. #5

Description

@d3vv

I found out this repo more friendly for windows builds.. It is about:
@sergeevabc #2

I suggest to use cygwin-patch first:

https://github.com/fd00/yacp/blob/master/dieharder/dieharder-3.31.1-1bl2.src.patch

Then we have an error like:

dab_dct.c: In function 'fDCT2':
dab_dct.c:251:41: error: 'M_PI' undeclared (first use in this function)
  251 |   output[i] += (double) input[j] * cos((M_PI / len) * (0.5 + j) * i);
      |                                         ^~~~
dab_dct.c:251:41: note: each undeclared identifier is reported only once for each function it appears in
dab_dct.c: In function 'iDCT2':
dab_dct.c:274:27: error: 'M_PI' undeclared (first use in this function)
  274 |   sum += input[j] * cos(((M_PI * j) / len) * (0.5 + i));
      |                           ^~~~
make[1]: *** [Makefile:780: libdieharder_la-dab_dct.lo] Error 1
make[1]: Leaving directory '/home/dew/repos/dieharder/libdieharder'
make: *** [Makefile:927: libwulf.time] Error 2

Solution for libdieharder/dab_dct.c:

$ diff libdieharder/dab_dct.c libdieharder/dab_dct.c.OLD
39,42d38
< #ifndef M_PI
<     #define M_PI 3.14159265358979323846
< #endif
<

Next too much errors like:

dab_filltree.c: In function 'insert':
dab_filltree.c:109:2: error: unknown type name 'uint'; did you mean 'int'?
  109 |  uint d = (startVal + 1) / 2;
      |  ^~~~
      |  int
dab_filltree.c:110:2: error: unknown type name 'uint'; did you mean 'int'?
  110 |  uint i = startVal;
      |  ^~~~
      |  int
make[1]: *** [Makefile:787: libdieharder_la-dab_filltree.lo] Error 1
make[1]: Leaving directory '/home/dew/repos/dieharder/libdieharder'
make: *** [Makefile:927: libwulf.time] Error 2

Solution:

$ diff include/dieharder/libdieharder.h include/dieharder/libdieharder.h.OLD
1,7d0
< #ifdef __MINGW32__
< #ifndef Types_H
< #define Types_H
< typedef unsigned int            uint;
< #endif
< #endif
<

Then we have a warning:

libtool: warning: undefined symbols not allowed in x86_64-w64-mingw32 shared libraries; building static only

Solution: add "-no-undefined" flag:

$ diff libdieharder/Makefile.am libdieharder/Makefile.am.OLD
22,23c22,23
< libdieharder_la_LDFLAGS = -no-undefined -version-number @DIEHARDER_LT_VERSION@
< libdieharder_la_CFLAGS = -std=gnu99 -Wall -pedantic
---
> libdieharder_la_LDFLAGS = -version-number @DIEHARDER_LT_VERSION@
> libdieharder_la_CFLAGS = -std=c99 -Wall -pedantic

I have used mingw64 from msys2 and clang (due to some bugs from gcc):

 ./autogen.sh
CC="clang" CFLAGS="-O3 -pipe" LDFLAGS="-static -Wl,-Bstatic" ./configure
make
strip dieharder/dieharder.exe

Static binary for Windows 64-bit attached below
dieharder.zip

@rurban Could it possible add patches to ur repo?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions