linkererrors when reducion phobos with dustmite

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Jan 8 19:55:57 UTC 2020


On Mon, Jan 06, 2020 at 10:27:09AM +0000, berni44 via Digitalmars-d-learn wrote:
> As mentioned on the dustmite website [1] I copied the folder std from
> Phobos in a separate folder and renamed it to mystd. The I changed all
> occurences of std by mystd in all files.
> 
> That works most of the time, but sometimes I get hundreds of linker
> errors I do not understand:
> 
> $> dmd -main -unittest -g -run mystd/variant.d
> 
> /usr/bin/ld: variant.o:(.data.rel.ro+0x68): undefined reference to
> `_D5mystd4meta12__ModuleInfoZ'
> /usr/bin/ld: variant.o:(.data.rel.ro+0x70): undefined reference to
> `_D5mystd6traits12__ModuleInfoZ'
> /usr/bin/ld: variant.o:(.data.rel.ro+0x78): undefined reference to
> `_D5mystd8typecons12__ModuleInfoZ'
> ...
> 
> Does anyone know, what's the problem here and how to get arround this?

Use dmd -i should solve the problem.

The problem is that you didn't specify some of the imported modules on
the command-line, and there was a reference to something in that module
other than a template (templates are instantiated in the importing
module, so they tend to work in spite of this omission).  When you don't
specify -i, dmd does not pull in imported files because it doesn't know
whether you're using separate compilation, in which case the missing
symbols would be resolved at link time and emitting them again would
cause a linker duplicate symbol error.


T

-- 
People tell me that I'm skeptical, but I don't believe them.


More information about the Digitalmars-d-learn mailing list