From e2ee1069a8f5d7f6cdbc71282382ef54b0d3d3e8 Mon Sep 17 00:00:00 2001 From: ithewei Date: Wed, 26 Jun 2024 22:16:18 +0800 Subject: [PATCH] fix mingw compile error --- CMakeLists.txt | 10 +++++----- http/server/FileCache.cpp | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b8c7f4d1..22293f1f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ option(WITH_MBEDTLS "with mbedtls library" OFF) option(WITH_KCP "compile event/kcp" OFF) -if(WIN32) +if(WIN32 OR MINGW) option(WITH_WEPOLL "compile event/wepoll -> use iocp" ON) option(ENABLE_WINDUMP "Windows MiniDumpWriteDump" OFF) option(BUILD_FOR_MT "build for /MT" OFF) @@ -126,7 +126,7 @@ endif() if(WITH_CURL) add_definitions(-DWITH_CURL) set(LIBS ${LIBS} curl) - if(WIN32) + if(WIN32 OR MINGW) set(LIBS ${LIBS} wldap32 advapi32 crypt32) endif() endif() @@ -156,7 +156,7 @@ if(WITH_MBEDTLS) set(LIBS ${LIBS} mbedtls mbedx509 mbedcrypto) endif() -if(WIN32) +if(WIN32 OR MINGW) add_definitions(-DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_WARNINGS -D_WIN32_WINNT=0x0600) set(LIBS ${LIBS} secur32 crypt32 winmm iphlpapi ws2_32) if(ENABLE_WINDUMP) @@ -167,7 +167,7 @@ endif() if(ANDROID) set(LIBS ${LIBS} log) -elseif(UNIX) +elseif(UNIX AND NOT MINGW) set(LIBS ${LIBS} pthread m dl) if(CMAKE_COMPILER_IS_GNUCC) set(LIBS ${LIBS} rt) @@ -181,7 +181,7 @@ endif() # see Makefile set(ALL_SRCDIRS . base ssl event event/kcp util cpputil evpp protocol http http/client http/server mqtt) set(CORE_SRCDIRS . base ssl event) -if(WIN32) +if(WIN32 OR MINGW) if(WITH_WEPOLL) set(CORE_SRCDIRS ${CORE_SRCDIRS} event/wepoll) endif() diff --git a/http/server/FileCache.cpp b/http/server/FileCache.cpp index a03596aec..8fb15f10d 100644 --- a/http/server/FileCache.cpp +++ b/http/server/FileCache.cpp @@ -8,7 +8,7 @@ #include "httpdef.h" // import http_content_type_str_by_suffix #include "http_page.h" // import make_index_of_page -#ifdef OS_WIN +#ifdef _MSC_VER #include #endif @@ -20,7 +20,7 @@ FileCache::FileCache() { } static int hv_open(char const* filepath, int flags) { -#ifdef OS_WIN +#ifdef _MSC_VER std::wstring_convert> conv; auto wfilepath = conv.from_bytes(filepath); int fd = _wopen(wfilepath.c_str(), flags);