msgpack-d icon indicating copy to clipboard operation
msgpack-d copied to clipboard

Windows builds must link with Ws2_32.lib`

Open mdparker opened this issue 3 years ago • 2 comments

common.d imports core.sys.windows.winsock2, but the dub recipe does not require the winsock library, causing linker errors for missing ntohl and ntohs. Perhaps a pragma(lib, "Ws2_32") in the Windows version block at the top of common.d?

mdparker avatar Jul 16 '21 16:07 mdparker

Okay, I see there's already a pragma in package.d. However, when compiling the example from the readme on Windows, I did see those missing symbol errors and had to link the example with winsock.

mdparker avatar Jul 16 '21 17:07 mdparker

We see linker errors too because of this. The pragma seems to be in the wrong module - if that package.d object file isn't pulled in (from the static lib), the embedded linker directive isn't used. I suggest moving it to dub.json, or better yet, getting rid of the manual endianness conversions (using ntohs and ntohl from winsock2) via std.bitmanip.nativeToBigEndian() etc.

kinke avatar Aug 09 '22 11:08 kinke