www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Linktime unresolved reference

reply donallen <donaldcallen gmail.com> writes:
I am trying to compile a small program (I can provide the source 
code if need be). It compiles but will not link:

dmd -I=../d_library -L='-lsqlite3' load_transactions.d 
../d_library/lib.o
/usr/bin/ld: ../d_library/lib.o: in function 
`_D3std6format8internal5write__T5roundTG64aZQmFNaNbNiNfKQrmmEQCgQCfQCbQBv13RoundingClassbaZb':
/home/dca/dlang/dmd-2.097.2/linux/bin64/../../src/phobos/std/format/in
ernal/write.d:3709: undefined reference to
`_D3std4math8hardware20FloatingPointControl8roundingFNaNbNdNiNeZk'
collect2: error: ld returned 1 exit status
Error: linker exited with status 1
make: *** [makefile:10: load_transactions] Error 1

The d demangler tells me this:

dca pangloss:/tmp/nvim$ echo 
'_D3std4math8hardware20FloatingPointControl8roundingFNaNbNdNiNeZk'|
/home/dca/dlang/dmd-2.097.2/linux/bin64/ddemangle
pure nothrow  property  nogc  trusted uint 
std.math.hardware.FloatingPointControl.rounding()

I do not reference the rounding function explicitly in my 
program, so I believe the reference is within the D libraries.

Any ideas/suggestions?

Thanks --
/Don Allen
Aug 22
next sibling parent donallen <donaldcallen gmail.com> writes:
I should have mentioned that I am doing this work on Slackware 
Linux system (current). dmd was installed with the curl script.
Aug 22
prev sibling parent reply jfondren <julian.fondren gmail.com> writes:
On Sunday, 22 August 2021 at 15:34:49 UTC, donallen wrote:
 Any ideas/suggestions?
Does this link? ```d void main() { import std.stdio : writeln; writeln(1.0f); } ``` That's enough to require that symbol: ```d $ dmd havefp.d $ nm -D havefp|grep -i _D3std4math8hardware20FloatingPointControl8roundingFNaNbNdNiNeZk 0000000000092a70 W _D3std4math8hardware20FloatingPointControl8roundingFNaNbNdN ``` If it doesn't link, my guess is that your platform isn't giving std.math.hardware the versions its wants, and perhaps that adding some -version=... flags to your command might get it to compile, and expose what your setup is missing. If it does link, my only guess is that you're including an .o built by an earlier version of dmd which mangled that differently.
Aug 22
parent donallen <donaldcallen gmail.com> writes:
On Sunday, 22 August 2021 at 15:53:07 UTC, jfondren wrote:
 On Sunday, 22 August 2021 at 15:34:49 UTC, donallen wrote:
 Any ideas/suggestions?
Does this link? ```d void main() { import std.stdio : writeln; writeln(1.0f); } ``` That's enough to require that symbol: ```d $ dmd havefp.d $ nm -D havefp|grep -i _D3std4math8hardware20FloatingPointControl8roundingFNaNbNdNiNeZk 0000000000092a70 W _D3std4math8hardware20FloatingPointControl8roundingFNaNbNdN ``` If it doesn't link, my guess is that your platform isn't giving std.math.hardware the versions its wants, and perhaps that adding some -version=... flags to your command might get it to compile, and expose what your setup is missing. If it does link, my only guess is that you're including an .o built by an earlier version of dmd which mangled that differently.
I didn't even bother testing your little code snippet above because your guess piqued my interest. I am resurrecting some work I had done with D last year and, in particular, I am using a library I wrote then providing some utility functions. Forcing a full rebuild of that library did the trick. Apparently bit-rot in an old .o exactly as you suggested. Thank you!
Aug 22