Hvordan kompilerer jeg C perfekt minimal hashing bibliotek på vinduer?

Indlæg af Hanne Mølgaard Plasc

Problem



Jeg har installeret Mingw og Msys.


Jeg har kørt bash configure for at oprette makefilen.


Men når jeg kører make får jeg følgende output


E:cmph-1.1>make
make  all-recursive
make[1]: Entering directory `/e/cmph-1.1'
Making all in src
make[2]: Entering directory `/e/cmph-1.1/src'
/bin/sh ../libtool --tag=CC   --mode=compile gcc -DHAVE\_CONFIG\_H -I. -I..     -Wall -Werror -MT hash.lo -MD -MP -MF .deps/hash.Tpo -c -o hash.lo hash.c
libtool: compile:  gcc -DHAVE\_CONFIG\_H -I. -I.. -Wall -Werror -MT hash.lo -MD -MP -MF .deps/hash.Tpo -c hash.c  -DDLL\_EXPORT -DPIC -o .libs/hash.o
libtool: compile:  gcc -DHAVE\_CONFIG\_H -I. -I.. -Wall -Werror -MT hash.lo -MD -MP -MF .deps/hash.Tpo -c hash.c -o hash.o >/dev/null 2>&1
mv -f .deps/hash.Tpo .deps/hash.Plo
/bin/sh ../libtool --tag=CC   --mode=compile gcc -DHAVE\_CONFIG\_H -I. -I..     -Wall -Werror -MT jenkins\_hash.lo -MD -MP -MF .deps/jenkins\_hash.Tpo -c -o jenkins\_hash.lo jenkins\_hash.c
libtool: compile:  gcc -DHAVE\_CONFIG\_H -I. -I.. -Wall -Werror -MT jenkins\_hash.lo -MD -MP -MF .deps/jenkins\_hash.Tpo -c jenkins\_hash.c  -DDLL\_EXPORT -DPIC -o .libs/jenkins\_hash.o
libtool: compile:  gcc -DHAVE\_CONFIG\_H -I. -I.. -Wall -Werror -MT jenkins\_hash.lo -MD -MP -MF .deps/jenkins\_hash.Tpo -c jenkins\_hash.c -o jenkins\_hash.o >/dev/null 2>&1
mv -f .deps/jenkins\_hash.Tpo .deps/jenkins\_hash.Plo
/bin/sh ../libtool --tag=CC   --mode=compile gcc -DHAVE\_CONFIG\_H -I. -I..     -Wall -Werror -MT vstack.lo -MD -MP -MF .deps/vstack.Tpo -c -o vstack.lo vstack.c
libtool: compile:  gcc -DHAVE\_CONFIG\_H -I. -I.. -Wall -Werror -MT vstack.lo -MD -MP -MF .deps/vstack.Tpo -c vstack.c  -DDLL\_EXPORT -DPIC -o .libs/vstack.o
libtool: compile:  gcc -DHAVE\_CONFIG\_H -I. -I.. -Wall -Werror -MT vstack.lo -MD -MP -MF .deps/vstack.Tpo -c vstack.c -o vstack.o >/dev/null 2>&1
mv -f .deps/vstack.Tpo .deps/vstack.Plo
/bin/sh ../libtool --tag=CC   --mode=compile gcc -DHAVE\_CONFIG\_H -I. -I..     -Wall -Werror -MT vqueue.lo -MD -MP -MF .deps/vqueue.Tpo -c -o vqueue.lo vqueue.c
libtool: compile:  gcc -DHAVE\_CONFIG\_H -I. -I.. -Wall -Werror -MT vqueue.lo -MD -MP -MF .deps/vqueue.Tpo -c vqueue.c  -DDLL\_EXPORT -DPIC -o .libs/vqueue.o
libtool: compile:  gcc -DHAVE\_CONFIG\_H -I. -I.. -Wall -Werror -MT vqueue.lo -MD -MP -MF .deps/vqueue.Tpo -c vqueue.c -o vqueue.o >/dev/null 2>&1
mv -f .deps/vqueue.Tpo .deps/vqueue.Plo
/bin/sh ../libtool --tag=CC   --mode=compile gcc -DHAVE\_CONFIG\_H -I. -I..     -Wall -Werror -MT graph.lo -MD -MP -MF .deps/graph.Tpo -c -o graph.lo graph.c
libtool: compile:  gcc -DHAVE\_CONFIG\_H -I. -I.. -Wall -Werror -MT graph.lo -MD -MP -MF .deps/graph.Tpo -c graph.c  -DDLL\_EXPORT -DPIC -o .libs/graph.o
libtool: compile:  gcc -DHAVE\_CONFIG\_H -I. -I.. -Wall -Werror -MT graph.lo -MD -MP -MF .deps/graph.Tpo -c graph.c -o graph.o >/dev/null 2>&1
mv -f .deps/graph.Tpo .deps/graph.Plo
/bin/sh ../libtool --tag=CC   --mode=compile gcc -DHAVE\_CONFIG\_H -I. -I..     -Wall -Werror -MT cmph.lo -MD -MP -MF .deps/cmph.Tpo -c -o cmph.lo cmph.c
libtool: compile:  gcc -DHAVE\_CONFIG\_H -I. -I.. -Wall -Werror -MT cmph.lo -MD -MP -MF .deps/cmph.Tpo -c cmph.c  -DDLL\_EXPORT -DPIC -o .libs/cmph.o
In file included from cmph.h:105:0,
                 from cmph.c:1:
cmph\_time.h: In function 'elapsed\_time\_in\_seconds':
cmph\_time.h:23:19: error: storage size of 'e\_time' isn't known
cmph\_time.h:24:4: error: implicit declaration of function 'gettimeofday' [-Werror=implicit-function-declaration]
cmph\_time.h:23:19: error: unused variable 'e\_time' [-Werror=unused-variable]
cmph\_time.h: In function 'elapsed\_time\_in\_useconds':
cmph\_time.h:34:19: error: storage size of 'e\_time' isn't known
cmph\_time.h:34:19: error: unused variable 'e\_time' [-Werror=unused-variable]
cmph.c: In function 'count\_nlfile\_keys':
cmph.c:154:18: error: variable 'ptr' set but not used [-Werror=unused-but-set-variable]
cc1.exe: all warnings being treated as errors


Jeg kæmper for at finde ud af, hvad jeg skal gøre for at få det til at kompilere.

Bedste reference


Hvis du ser i det, at headerfilen, vil du se nær toppen af ​​denne konstruktion:


#ifdef WIN32
// include headers to use gettimeofday
#else
    #ifdef \_\_GNUC\_\_
    #include <sys/time.h>
    #include <sys/resource.h>
    #endif
#endif


Det ser ud til at du ikke ender i den anden halvdel, hvorfra du får deklarationerne fra gettimeofday() og struct timeval.


Jeg er ikke meget bekendt med MinGW - definerer den WIN32? Hvis det er tilfældet, skal du muligvis omarbejde denne preprocessor logik til at gøre, hvad du vil. Til reference fungerer det fint i cygwin.

Andre referencer 1


Se på denne patch, der indeholder løsningen for at kompilere på mingw: http://sourceforge.net/p/cmph/patches/3/[8]