From 55a6479ea24a91cf500ad611d51fa39483f54b7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= Date: Sun, 24 Nov 2019 00:17:32 +0000 Subject: [PATCH] Fix compilation for Windows with MinGW --- Makefile | 4 ++++ src/darkunistd.h | 2 +- src/gemm.c | 2 +- src/getopt.h | 6 +++--- src/gettimeofday.h | 6 +++--- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index c5999128..7db7f869 100644 --- a/Makefile +++ b/Makefile @@ -73,6 +73,10 @@ endif CFLAGS+=$(OPTS) +ifneq (,$(findstring MSYS_NT,$(OS))) +LDFLAGS+=-lws2_32 +endif + ifeq ($(OPENCV), 1) COMMON+= -DOPENCV CFLAGS+= -DOPENCV diff --git a/src/darkunistd.h b/src/darkunistd.h index d2d555c3..6c06aef1 100644 --- a/src/darkunistd.h +++ b/src/darkunistd.h @@ -7,7 +7,7 @@ * Please add functionality as needed */ -#include +#include #include /* for _getcwd() and _chdir() */ #include "getopt.h" #include diff --git a/src/gemm.c b/src/gemm.c index 51f77cac..9d95e054 100644 --- a/src/gemm.c +++ b/src/gemm.c @@ -512,7 +512,7 @@ static inline int popcnt_32(uint32_t val32) { //---------------------------- -#if (defined(__AVX__) && defined(__x86_64__)) || defined(_WIN64) +#if (defined(__AVX__) && defined(__x86_64__)) || (defined(_WIN64) && !defined(__MINGW32__)) #ifdef _WIN64 #include diff --git a/src/getopt.h b/src/getopt.h index 431ba864..66ab5dfb 100644 --- a/src/getopt.h +++ b/src/getopt.h @@ -67,7 +67,7 @@ #include #include #define WIN32_LEAN_AND_MEAN -#include +#include #ifdef __cplusplus extern "C" { @@ -190,13 +190,13 @@ extern "C" { * Parse long options in argc/argv argument vector. * Returns -1 if short_too is set and the option does not match long_options. */ -static int parse_long_options(char* const* nargv, const char* options, const struct option* long_options, int* idx, int short_too); +/* static int parse_long_options(char* const* nargv, const char* options, const struct option* long_options, int* idx, int short_too); */ /* * getopt_internal -- * Parse argc/argv argument vector. Called by user level routines. */ -static int getopt_internal(int nargc, char* const* nargv, const char* options, const struct option* long_options, int* idx, int flags); +/* static int getopt_internal(int nargc, char* const* nargv, const char* options, const struct option* long_options, int* idx, int flags); */ /* * getopt_long -- diff --git a/src/gettimeofday.h b/src/gettimeofday.h index 4a9df673..2e96dd2b 100644 --- a/src/gettimeofday.h +++ b/src/gettimeofday.h @@ -1,9 +1,9 @@ #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN -#include -#include +#include +#include #include -#include < time.h > +#include #include "darknet.h" #define CLOCK_REALTIME (1)