/usr/bin/ld: [...] undefined reference to _D3std6format6internal6write...

Anonymouse zorael at gmail.com
Thu Dec 22 15:32:28 UTC 2022


On Tuesday, 20 December 2022 at 20:55:08 UTC, Paul Backus wrote:

Apologies for the late reply.

> On Tuesday, 20 December 2022 at 20:01:04 UTC, Anonymouse wrote:
>> What does `-allinst` even do
>
> `-allinst` tells the compiler to generate code for all 
> instantiated templates, even if it thinks that code has already 
> been generated in a different object file.
[...]

I see. That makes sense. When things fail (requiring `-allinst`), 
is that a bug I should report or a fact of life to lament?

>> and why does it seem to be insufficient here?
>
> Hard to say without more information. Are you compiling with 
> `-preview=dip1000`? If not, does adding that flag fix the error?

I'm not compiling with `dip1000`. Adding it just adds some extra 
lines to the top of the linker errors.

Full demangled non-`dip1000` error, slightly formatted for 
readability;

```
/usr/bin/ld: 
../../.dub/packages/requests-2.0.9/requests/.dub/build/[...]/librequests.a: in function `pure @safe void std.format.internal.write.formatValueImpl!(void delegate(scope const(char)[]) pure nothrow @safe, ulong, char).formatValueImpl(ref void delegate(scope const(char)[]) pure nothrow @safe, const(ulong), scope ref const(std.format.spec.FormatSpec!(char).FormatSpec))':
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/std/format/internal/write.d:171: undefined reference to `pure nothrow @nogc @trusted const(char)[] std.format.internal.write.formatValueImpl!(void delegate(scope const(char)[]) pure nothrow @safe, ulong, char).formatValueImpl(ref void delegate(scope const(char)[]) pure nothrow @safe, const(ulong), scope ref const(std.format.spec.FormatSpec!(char).FormatSpec)).__lambda5!(ulong).__lambda5(ref ulong)'

/usr/bin/ld: 
../../.dub/packages/requests-2.0.9/requests/.dub/build/[...]/librequests.a: in function `pure @safe immutable(char)[] std.algorithm.searching.find!(std.algorithm.mutation.stripLeft!(immutable(char)[], char).stripLeft(immutable(char)[], char).__lambda3, immutable(char)[]).find(immutable(char)[])':
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/std/algorithm/searching.d:1858: undefined reference to `pure nothrow @nogc @safe bool std.algorithm.mutation.stripLeft!(immutable(char)[], char).stripLeft(immutable(char)[], char).__lambda3!(dchar).__lambda3(dchar)'

collect2: error: ld returned 1 exit status
Error gdc failed with exit code 1.
```

In this case it's even in an external dependency (`requests`), 
which compiles by itself but not when dub builds my thing with it.

I'm not sure what to do.


More information about the Digitalmars-d-learn mailing list