www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Linker error

reply Jerry <labuurii gmail.com> writes:
Hello, I am trying to compile a 1 year old project of mine which 
uses htmld and vibed. But I get this weird linker error which 
does not make any sense to me atleast. I am using Windows 7 and 
dub.

htmld 0.3.6: target for configuration "library" is up to date.
taggedalgebraic 0.10.12: target for configuration "library" is up 
to date.
eventcore 0.8.40: target for configuration "winapi" is up to date.
stdx-allocator 2.77.5: target for configuration "library" is up 
to date.
vibe-core 1.5.0: target for configuration "winapi" is up to date.
vibe-d:utils 0.8.4: target for configuration "library" is up to 
date.
vibe-d:data 0.8.4: target for configuration "library" is up to 
date.
mir-linux-kernel 1.0.1: target for configuration "library" is up 
to date.
vibe-d:crypto 0.8.4: target for configuration "library" is up to 
date.
diet-ng 1.5.0: target for configuration "library" is up to date.
vibe-d:stream 0.8.4: target for configuration "library" is up to 
date.
vibe-d:textfilter 0.8.4: target for configuration "library" is up 
to date.
vibe-d:inet 0.8.4: target for configuration "library" is up to 
date.
vibe-d:tls 0.8.4: target for configuration "openssl-mscoff" is up 
to date.
vibe-d:http 0.8.4: target for configuration "library" is up to 
date.
vibe-d:mail 0.8.4: target for configuration "library" is up to 
date.
vibe-d:mongodb 0.8.4: target for configuration "library" is up to 
date.
vibe-d:redis 0.8.4: target for configuration "library" is up to 
date.
vibe-d:web 0.8.4: target for configuration "library" is up to 
date.
vibe-d 0.8.4: target for configuration "vibe-core" is up to date.
my_stuff ~master: building configuration "updater-local"...
Linking...
vibe-d_web.lib(common.obj) : warning LNK4255: library contain 
multiple objects of the same name; lin
king object as if no debug info
eventcore.lib(driver.obj) : warning LNK4255: library contain 
multiple objects of the same name; link
ing object as if no debug info
eventcore.lib(driver.obj) : warning LNK4255: library contain 
multiple objects of the same name; link
ing object as if no debug info
eventcore.lib(core.obj) : warning LNK4255: library contain 
multiple objects of the same name; linkin
g object as if no debug info
my_stuff.obj : error LNK2019: unresolved external symbol 
_D60TypeInfo_xS4html3dom__T15ChildrenForwar
dTCQBfQBd4NodeVnnZQBi6__initZ referenced in function 
_D8typecons__T11ThrowOnNullTS4html3dom__T15Chil
drenForwardTCQBfQBd4NodeVnnZQBiZQCn9__xtoHashFNbNeKxSQDu__TQDoTQDeZQDwZm
.dub\build\updater-local-debug-windows-x86_64-dmd_2083-F0ADCB72FF986B7D6354817AF1E3A045\my_stuff.exe
  : fatal error LNK1120: 1 unresolved externals
Error: linker exited with status 1120
dmd failed with exit code 1.

I tried to find the typecons.ThrowOnNull thing in the standard 
library but that one does not exist. So I am pretty confused 
about what is going on here.

Thank you.
Jan 21
parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
On 1/21/19 3:37 PM, Jerry wrote:
 Hello, I am trying to compile a 1 year old project of mine which uses 
 htmld and vibed. But I get this weird linker error which does not make 
 any sense to me atleast. I am using Windows 7 and dub.
 
 htmld 0.3.6: target for configuration "library" is up to date.
 taggedalgebraic 0.10.12: target for configuration "library" is up to date.
 eventcore 0.8.40: target for configuration "winapi" is up to date.
 stdx-allocator 2.77.5: target for configuration "library" is up to date.
 vibe-core 1.5.0: target for configuration "winapi" is up to date.
 vibe-d:utils 0.8.4: target for configuration "library" is up to date.
 vibe-d:data 0.8.4: target for configuration "library" is up to date.
 mir-linux-kernel 1.0.1: target for configuration "library" is up to date.
 vibe-d:crypto 0.8.4: target for configuration "library" is up to date.
 diet-ng 1.5.0: target for configuration "library" is up to date.
 vibe-d:stream 0.8.4: target for configuration "library" is up to date.
 vibe-d:textfilter 0.8.4: target for configuration "library" is up to date.
 vibe-d:inet 0.8.4: target for configuration "library" is up to date.
 vibe-d:tls 0.8.4: target for configuration "openssl-mscoff" is up to date.
 vibe-d:http 0.8.4: target for configuration "library" is up to date.
 vibe-d:mail 0.8.4: target for configuration "library" is up to date.
 vibe-d:mongodb 0.8.4: target for configuration "library" is up to date.
 vibe-d:redis 0.8.4: target for configuration "library" is up to date.
 vibe-d:web 0.8.4: target for configuration "library" is up to date.
 vibe-d 0.8.4: target for configuration "vibe-core" is up to date.
 my_stuff ~master: building configuration "updater-local"...
 Linking...
 vibe-d_web.lib(common.obj) : warning LNK4255: library contain multiple 
 objects of the same name; lin
 king object as if no debug info
 eventcore.lib(driver.obj) : warning LNK4255: library contain multiple 
 objects of the same name; link
 ing object as if no debug info
 eventcore.lib(driver.obj) : warning LNK4255: library contain multiple 
 objects of the same name; link
 ing object as if no debug info
 eventcore.lib(core.obj) : warning LNK4255: library contain multiple 
 objects of the same name; linkin
 g object as if no debug info
 my_stuff.obj : error LNK2019: unresolved external symbol 
 _D60TypeInfo_xS4html3dom__T15ChildrenForwar
 dTCQBfQBd4NodeVnnZQBi6__initZ referenced in function 
 _D8typecons__T11ThrowOnNullTS4html3dom__T15Chil
 drenForwardTCQBfQBd4NodeVnnZQBiZQCn9__xtoHashFNbNeKxSQDu__TQDoTQDeZQDwZm
 ..dub\build\updater-local-debug-windows-x86_64-dmd_2083-F0ADCB72FF986B7D6354817AF
E3A045\my_stuff.exe 
 
   : fatal error LNK1120: 1 unresolved externals
 Error: linker exited with status 1120
 dmd failed with exit code 1.
 
 I tried to find the typecons.ThrowOnNull thing in the standard library 
 but that one does not exist. So I am pretty confused about what is going 
 on here.
 
 Thank you.
I had a similar problem that I fixed myself actually last dconf: https://issues.dlang.org/show_bug.cgi?id=17968 This looks almost identical as the issue was in the generated xtoHash function. What version of the compiler are you using? My issue was fixed in 2.080.1, and then a followup fix in 2.081.1. -Steve
Jan 21
next sibling parent Jerry <labuurii gmail.com> writes:
On Monday, 21 January 2019 at 21:02:23 UTC, Steven Schveighoffer 
wrote:
 What version of the compiler are you using? My issue was fixed 
 in 2.080.1, and then a followup fix in 2.081.1.

 -Steve
Hello! I am using 2.084. Interestingly it works with LDC 1.9 (frontend 2.79) and that just works fine. Bisecting dmd versions. - Jerry
Jan 21
prev sibling next sibling parent reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Mon, Jan 21, 2019 at 04:02:23PM -0500, Steven Schveighoffer via
Digitalmars-d-learn wrote:
 On 1/21/19 3:37 PM, Jerry wrote:
 Hello, I am trying to compile a 1 year old project of mine which
 uses htmld and vibed. But I get this weird linker error which does
 not make any sense to me atleast. I am using Windows 7 and dub.
[...]
 my_stuff.obj : error LNK2019: unresolved external symbol
 _D60TypeInfo_xS4html3dom__T15ChildrenForwar
 dTCQBfQBd4NodeVnnZQBi6__initZ referenced in function
 _D8typecons__T11ThrowOnNullTS4html3dom__T15Chil
 drenForwardTCQBfQBd4NodeVnnZQBiZQCn9__xtoHashFNbNeKxSQDu__TQDoTQDeZQDwZm
 ..dub\build\updater-local-debug-windows-x86_64-dmd_2083-F0ADCB72FF986B7D6354817AF1E3A045\my_stuff.exe
 
  : fatal error LNK1120: 1 unresolved externals
 Error: linker exited with status 1120
 dmd failed with exit code 1.
[...] Looks like a problem with stale cached object files. Try: rm dub.selections.json dub build --force (Be sure to back up dub.selections.json before doing this, if you have customized it by hand.) T -- Music critic: "That's an imitation fugue!"
Jan 21
parent reply Jerry <labuurii gmail.com> writes:
On Monday, 21 January 2019 at 21:37:22 UTC, H. S. Teoh wrote:
 On Mon, Jan 21, 2019 at 04:02:23PM -0500, Steven Schveighoffer 
 via Digitalmars-d-learn wrote:
 On 1/21/19 3:37 PM, Jerry wrote:
 [...]
[...]
 [...]
[...] Looks like a problem with stale cached object files. Try: rm dub.selections.json dub build --force (Be sure to back up dub.selections.json before doing this, if you have customized it by hand.) T
Still same error, on both 2.78 and 2.84.
Jan 21
parent reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Mon, Jan 21, 2019 at 10:19:00PM +0000, Jerry via Digitalmars-d-learn wrote:
 On Monday, 21 January 2019 at 21:37:22 UTC, H. S. Teoh wrote:
[...]
 Looks like a problem with stale cached object files.  Try:
 
 	rm dub.selections.json
 	dub build --force
 
 (Be sure to back up dub.selections.json before doing this, if you
 have customized it by hand.)
[...]
 Still same error, on both 2.78 and 2.84.
Hmm. OK, then I've no idea what's wrong, sorry. T -- Dogs have owners ... cats have staff. -- Krista Casada
Jan 21
parent Jerry <labuurii gmail.com> writes:
On Monday, 21 January 2019 at 22:31:15 UTC, H. S. Teoh wrote:
 On Mon, Jan 21, 2019 at 10:19:00PM +0000, Jerry via 
 Digitalmars-d-learn wrote:
 On Monday, 21 January 2019 at 21:37:22 UTC, H. S. Teoh wrote:
[...]
 Looks like a problem with stale cached object files.  Try:
 
 	rm dub.selections.json
 	dub build --force
 
 (Be sure to back up dub.selections.json before doing this, 
 if you
 have customized it by hand.)
[...]
 Still same error, on both 2.78 and 2.84.
Hmm. OK, then I've no idea what's wrong, sorry. T
Thank you for all the effort!
Jan 21
prev sibling parent reply Jerry <labuurii gmail.com> writes:
On Monday, 21 January 2019 at 21:02:23 UTC, Steven Schveighoffer 
wrote:
 On 1/21/19 3:37 PM, Jerry wrote:
 [...]
I had a similar problem that I fixed myself actually last dconf: https://issues.dlang.org/show_bug.cgi?id=17968 This looks almost identical as the issue was in the generated xtoHash function. What version of the compiler are you using? My issue was fixed in 2.080.1, and then a followup fix in 2.081.1. -Steve
Ok, I get the same linker error down to version 2.74. Below that my eventcore version does not compile. Atleast LDC can compile so I can move forward. I will try to dustmite this tomorrow.
Jan 21
parent Steven Schveighoffer <schveiguy gmail.com> writes:
On 1/21/19 5:28 PM, Jerry wrote:
 On Monday, 21 January 2019 at 21:02:23 UTC, Steven Schveighoffer wrote:
 On 1/21/19 3:37 PM, Jerry wrote:
 [...]
I had a similar problem that I fixed myself actually last dconf: https://issues.dlang.org/show_bug.cgi?id=17968 This looks almost identical as the issue was in the generated xtoHash function. What version of the compiler are you using? My issue was fixed in 2.080.1, and then a followup fix in 2.081.1.
Ok, I get the same linker error down to version 2.74. Below that my eventcore version does not compile. Atleast LDC can compile so I can move forward. I will try to dustmite this tomorrow.
This was a PITA for me when it happened (I used dustmite to go down to a pretty small version). I was essentially blocked on my work in iopipe until this was fixed. The issue I ran starts with dmd generating a function xtoHash for structs where you don't define toHash. In certain cases (and these can be very weird indeed), dmd generates a function which, for each of its members, calls essentially typeid(x).toHash(&x). In the case of a struct that contains a class reference, this all goes fine, but the compiler doesn't generate the TypeInfo for the class when it should in these certain cases (in particular, the TypeInfo_Const for that class reference). The reason I feel like your error is very very similar, is because you show the missing symbol as being the InitZ, which is the TypeInfo initializer of something, and you see the symbol that requires it as being an xtoHash symbol. Not knowing your code base, it's hard to know what exact situation you're in. But hopefully this helps you get an understanding as to why it might happen. I think in my case, it was a template class in an auto function, within an import (hard now to remember the details). In fact, the root cause is still there, I just added a workaround in the xtoHash generation (that cheats and uses typeid(Object) instead of the real typeid, since it's a virtual function call anyway). See the related bug report with the root cause: https://issues.dlang.org/show_bug.cgi?id=18833, maybe it helps you relate to what is happening. -Steve
Jan 21