Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to compile Drogon on Windows with MinGW64 #2274

Open
HanWangwang opened this issue Mar 10, 2025 · 2 comments
Open

Failed to compile Drogon on Windows with MinGW64 #2274

HanWangwang opened this issue Mar 10, 2025 · 2 comments

Comments

@HanWangwang
Copy link

HanWangwang commented Mar 10, 2025

Describe the bug
I try to compile drogon with MinGW64.
Linker errors occur in hiredis when compiling drogon_ctrl and examples.
If don't build drogon_ctrl and examples or don't build redis, it will success.
When using the hiredis library alone, it works properly; when using Drogon alone, it works properly; however, when they are used together, they do not work properly.
To Reproduce
Steps to reproduce the behavior:

  1. conan install .. -s compiler="gcc" -s compiler.version=13.2 -s compiler.cppstd=17 -s compiler.libcxx=libstdc++11 -s build_type=Debug --output-folder . --build=missing
  2. cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="D:/dev" -G "MinGW Makefiles"
  3. cmake --build . --parallel --target install
D:/dev/mingw/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/97083/.conan2/p/b/hireddbb584c483d32/p/lib/libhiredis.a(sockcompat.c.obj): in function `win32_gai_strerror':
C:/Users/97083/.conan2/p/b/hireddbb584c483d32/b/src/sockcompat.c:146:(.text+0x3aa): undefined reference to `gai_strerrorA'
D:/dev/mingw/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/97083/.conan2/p/b/hireddbb584c483d32/p/lib/libhiredis.a(sockcompat.c.obj): in function `win32_poll':
C:/Users/97083/.conan2/p/b/hireddbb584c483d32/b/src/sockcompat.c:244:(.text+0x84a): undefined reference to `WSAPoll'

It looks like a ws2_32 linking issue, but explicitly adding ws2_32 in the CMakeLists did not resolve the problem.
I switch to MinGW 14.2 did not resolve the problem.
Platform

  • OS: windows10
  • MinGW64:13.2 or 14.2
@an-tao
Copy link
Member

an-tao commented Mar 11, 2025

This seems to be an issue with the hiredis library's support for MinGW64

@HanWangwang
Copy link
Author

I tried again, and after modifying findHiredis.cmake, the issue was resolved.

if(MINGW)
        target_link_libraries(Hiredis_lib INTERFACE ws2_32)
endif()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants