msgpack link failure - non-transitive pragma(lib)?
TED_996
ted_996 at gmail.com
Fri May 11 12:35:52 UTC 2018
I've been trying to debug this for a long time now. I am trying
to build one of the msgpack examples (examples/upacker_foreach.d)
and the linking failed. I have since succeeded and I'm trying to
find out if this is intended behavior or a bug in D (not msgpack,
I think).
TL;DR: it seems to me like the pragma(lib, "ws2_32"); in
core.sys.windows.winsock2, imported in msgpack.common, imported
in msgpack (package.d), imported in my source files, does not
hold; this was fixed when I added the pragma in my source file
too.
Versions: Windows 10, dmd 2.080.0, dub 1.9.0
The dub build output:
Performing "debug" build using D:\D\dmd2\windows\bin\dmd.exe for
x86.
msgpack-d 1.0.0-beta.6: target for configuration "library" is up
to date.
hw ~master: building configuration "application"...
Linking...
OPTLINK (R) for Win32 Release 8.00.17
Copyright (C) Digital Mars 1989-2013 All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
.dub\build\application-debug-windows-x86-dmd_2080-1E3111031ACEC4AEF53C62127331208A\hw.obj(hw)
Error 42: Symbol Undefined _ntohl at 4
.dub\build\application-debug-windows-x86-dmd_2080-1E3111031ACEC4AEF53C62127331208A\hw.obj(hw)
Error 42: Symbol Undefined _ntohs at 4
Error: linker exited with status 2
D:\D\dmd2\windows\bin\dmd.exe failed with exit code 1.
dub.json:
{
"name": "hw",
"authors": [
"ted_996"
],
"description": "A minimal D application.",
"copyright": "Copyright © 2018, ted_996",
"license": "proprietary",
"dependencies": {
"msgpack-d": ">=1.0.0-beta.6"
}
}
After some digging, I found that other binaries that used msgpack
(DCD) were importing ws2_32, but it seemed like my binary was
not. Both debug and release and x86 and x64 versions were failing
to link; msgpack built fine but probably only the msgpack.lib
file (no final link).
However, when I (counter-intuitively, for me) added pragma(lib,
"ws2_32"); to my own source files, it built successfully. Should
that have been necessary? it was not in any examples. What gives?
Thanks!
More information about the Digitalmars-d-learn
mailing list