Skip to content

Commit

Permalink
fix mingw compile error
Browse files Browse the repository at this point in the history
  • Loading branch information
ithewei committed Jun 26, 2024
1 parent 0325f2d commit e2ee106
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions http/server/FileCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <codecvt>
#endif

Expand All @@ -20,7 +20,7 @@ FileCache::FileCache() {
}

static int hv_open(char const* filepath, int flags) {
#ifdef OS_WIN
#ifdef _MSC_VER
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> conv;
auto wfilepath = conv.from_bytes(filepath);
int fd = _wopen(wfilepath.c_str(), flags);
Expand Down

0 comments on commit e2ee106

Please sign in to comment.