I'm currently build the Drogon framework on a Windows platform with MinGW.
Drogon integrated the hiredis library.
While building the project, I encountered the following linker errors:
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/hiredaa6f1e6e3ba57/p/lib/libhiredis.a(sockcompat.c.obj): in function `win32_gai_strerror':
C:/Users/97083/.conan2/p/b/hiredaa6f1e6e3ba57/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/hiredaa6f1e6e3ba57/p/lib/libhiredis.a(sockcompat.c.obj): in function `win32_poll':
C:/Users/97083/.conan2/p/b/hiredaa6f1e6e3ba57/b/src/sockcompat.c:244:(.text+0x84a): undefined reference to `WSAPoll'
collect2.exe: error: ld returned 1 exit status
mingw32-make[2]: *** [drogon_ctl\CMakeFiles\drogon_ctl.dir\build.make:780: drogon_ctl/drogon_ctl.exe] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:652: drogon_ctl/CMakeFiles/drogon_ctl.dir/all] Error 2
Development Environment:
Windows 10
MinGW-w64 14.2
Drogon framework
hiredis library(installde by conan2) drogon and hiredis both build static lib。
Here's a summary of my setup and the steps I've taken so far:
Verified hiredis Compilation: Compiled the hiredis example code using MinGW without issues, indicating that hiredis can be built correctly in my environment.
Compiling the parts of Drogon unrelated to hiredis, the build succeeds.
Explicit Linking: Ensured that the ws2_32 library is explicitly linked in my CMake configuration:
target_link_libraries(MyApp PRIVATE ws2_32)
- Checked Windows API Version Macro: Defined the _WIN32_WINNT macro to ensure compatibility with the required Windows API functions:
add_definitions(-D_WIN32_WINNT=0x0601) # Windows 7 or later
- Verified Symbol Presence: Used the nm command to inspect the libws2_32.a library and confirmed that both gai_strerrorA and WSAPoll symbols are present.
Despite these efforts, the linker errors persist. I have no more idea about this error.
I'm seeking guidance on how to resolve these linker errors. Has anyone faced similar issues or can provide insights into potential solutions? Any advice or recommendations would be greatly appreciated.
Thank you in advance for your assistance!