2 ms·
I had a look at the post. It only shows how to tell the Go compiler how to use Zig as the C Compiler. In our case, what we need is to tell Zig to link the objec
by brabel 2y ago
I had a look at the post. It only shows how to tell the Go compiler how to use Zig as the C Compiler.
In our case, what we need is to tell Zig to link the object files created by D.
I've had a look and saw that Zig is still implementing the `ld` command, but there's already a `ld.ldd` command which might work if you know what magical options to use. I've tried to link my D object file but it can't find a whole lot of generated symbols, and a quick search online does not tell me where do I get those symbols from. That's always what happens when I try to do stuff with D that's not well documented.
I tried this (used the dmd -v option to get the linker command):
zig ld.lld -L/Users/me/dlang/dmd-2.109.1/osx/bin/../lib app.o
Output:
```
ld.lld: error: undefined symbol: _d_assert_msg
>>> referenced by myd/source/app.d
>>> app.o:(_D4core8internal5newaa__T6makeAATAyaTiZQoFNaNeHQoiZSQByQBwQBq7AAShell)
>>> referenced by myd/source/app.d
>>> app.o:(_D3std6format5write__T14formattedWriteTSQBm5stdio4File17LockingTextWriterTaTS3app__T9StringMapTiZQnZQDaFNfKQCqMxAaQBmZk)
>>> referenced by myd/source/app.d
>>> app.o:(_D3std6format5write__T14formattedWriteTSQBm5stdio4File17LockingTextWriterTaTS3app__T9StringMapTiZQnZQDaFNfKQCqMxAaQBmZk)
>>> referenced 27 more times
ld.lld: error: undefined symbol: _aaLen
>>> referenced by myd/source/app.d
>>> app.o:(_D4core8internal5newaa__T6makeAATAyaTiZQoFNaNeHQoiZSQByQBwQBq7AAShell)
>>> referenced by myd/source/app.d
>>> app.o:(_D3std6format8internal5write__T15formatValueImplTSQBw5stdio4File17LockingTextWriterTHiHAyaiTaZQClFNfKQCaQuMKxSQEeQEd4spec__T10FormatSpecTaZQpZv)
>>> referenced by myd/source/app.d
>>> app.o:(_D3std6format8internal5write__T15formatValueImplTSQBw5stdio4File17LockingTextWriterTHAyaiTaZQCjFNfKQByQsMKxSQEcQEb4spec__T10FormatSpecTaZQpZv)
ld.lld: error: too many errors emitted, stopping now (use --error-limit=0 to see all errors)
```
Do you know how to get past that?
- WalterBright 2y agoLooks like the D runtime library isn't being linked in.
- zellyn 2y agoI have to confess to mostly just lurking Zig with interest, but not _actually_ knowing what I'm talking about. I do know their linker game has improved a _lot_ since that old Go article, so it's quite likely that Zig can do what you want. You might want to try their IRC or Discord.