Linker issues with DMD and LDC

Thomas Gregory charles.gregory940 at topper.wku.edu
Fri Nov 12 19:50:24 UTC 2021


I get this error when trying to compile a program using 
[dhtslib](https://github.com/blachlylab/dhtslib) with DMD or any 
LDC version < 1.25.0.
```
_D39TypeInfo_S7dhtslib3sam6record9SAMRecord6__initZ: error: 
undefined reference to 
`_D7dhtslib3sam6record9SAMRecord15__fieldPostblitMFNbNiNlNeZv'
```
Though I only experience this when trying to create an array of 
`SAMRecord`s.

One solution I have found is using `std.array.Appender` instead 
of arrays. Another solution I have found is to define an explicit 
postblit for `SAMRecord`, though the implicitly generated 
postblit should work.

Looking through ldc changelogs, the closest thing I could 
attribute this to is this change for ldc-1.25.0:

> - Struct TypeInfos are emitted into referencing object files 
> only, and special TypeInfo member functions into the owning 
> object file only. (#3491)

I posted this question 
[previously](https://forum.dlang.org/post/flpztfooingrpkxanovj@forum.dlang.org), though I explained the problem poorly.

I don't understand why my fixes work or what is causing the issue 
in the first place. Is there something I should be doing 
differently? Is this a compiler or language bug?


More information about the Digitalmars-d-learn mailing list