gdc 12.1: undefined references when linking separately compiled files

kdevel kdevel at vogtner.de
Sat May 28 14:16:51 UTC 2022


On Saturday, 28 May 2022 at 13:12:46 UTC, kdevel wrote:
> Any ideas?

ppinsta.d
```
import std.stdio : write, writeln;
import parser; // <- comment this out and gdc links

void main ()
{
    string [string] h;
    writeln (h);
}
```

parser.d
```
module parser;
import std.regex : regex;

private immutable auto VariableName = regex("^[a-zA-Z]*$");
```

Compile in one go:
```
$ gdc -o ppinsta ppinsta.d parser.d
$ ./ppinsta
[]
```

Compiled separately:
```
$ gdc -c ppinsta.d
$ gdc -c parser.d
$ gdc -o ppinsta ppinsta.o parser.o
ppinsta.o: In function 
`_D3std6format8internal5write__T8getWidthTAyaZQoFNaNfQlZl':
ppinsta.d:(.text+0x11ea): undefined reference to 
`_D3std9algorithm9searching__T3allSQBg6format8internal5write__T8getWidthTAyaZQoFQhZ9__lambda2Z__TQCpTQBcZQCxMFNaNfQBpZb'
ppinsta.o: In function 
`_D3std6format8internal5write__T8getWidthTAaZQnFNaNfQkZl':
ppinsta.d:(.text+0x16ba): undefined reference to 
`_D3std9algorithm9searching__T3allSQBg6format8internal5write__T8getWidthTAaZQnFQgZ9__lambda2Z__TQCoTQBbZQCwMFNaNfQBoZb'
ppinsta.o: In function 
`_D3std6format8internal5write__T20formatValueImplUlongTSQCb5array__T8AppenderTAyaZQoTaZQCdFNaNfKQBpmIbMKxSQDzQDy4spec__T10FormatSpecTaZQpZv':
ppinsta.d:(.text+0x21d9): undefined reference to 
`_D3std9algorithm9searching__T3allSQBg6format8internal5write__T20formatValueImplUlongTSQDg5array__T8AppenderTAyaZQoTaZQCdFKQBlmIbMKxSQFaQDu4spec__T10FormatSpecTaZQpZ10__lambda16Z__TQFvTAaZQGcMFNaNfQmZb'
ppinsta.d:(.text+0x2268): undefined reference to 
`_D3std9algorithm9searching__T3allSQBg6format8internal5write__T20formatValueImplUlongTSQDg5array__T8AppenderTAyaZQoTaZQCdFKQBlmIbMKxSQFaQDu4spec__T10FormatSpecTaZQpZ10__lambda17Z__TQFvTAaZQGcMFNaNfQmZb'
ppinsta.o: In function 
`_D3std6format8internal5write__T8getWidthTAwZQnFNaNbNiNfQoZl':
ppinsta.d:(.text+0x2996): undefined reference to 
`_D3std9algorithm9searching__T3allSQBg6format8internal5write__T8getWidthTAwZQnFQgZ9__lambda2Z__TQCoTQBbZQCwMFNaNbNiNfQBsZb'
collect2: error: ld returned 1 exit status
```




More information about the Digitalmars-d-learn mailing list