This error requires multiple modules to reproduce.
Recursive imports, `static this`, and `package.d`-style imports are all apparently required to cause the error.
app.d:
import foo;
void main() {}
static this() {}
foo/package.d:
import app;
The output of `dmd app.d` is:
app.o:(.rodata+0x18): undefined reference to `_D3foo12__ModuleInfoZ'
collect2: error: ld returned 1 exit status
--- errorlevel 1
Comment #1 by alphaglosined — 2022-11-16T04:18:09Z
The other modules must be compiled into your binary.
You can use -i to do this automatically for small build-manager-less software.
Comment #2 by andy-hanson — 2022-11-16T05:09:49Z
`dmd app.d -i` works, but why does `dmd app.d foo/package.d` not work?
Comment #3 by alphaglosined — 2022-11-16T05:26:57Z
It may be because of no module declaration.
If it works with the module declaration, it's still a bug, but with a different cause I think (so reopen).
Comment #4 by andy-hanson — 2022-11-16T05:48:06Z
OK, It does work if I add `module foo;` at the beginning of `foo/package.d`.
Comment #5 by robert.schadek — 2024-12-13T18:47:24Z