DMD Stdio Linker Oddities
Jake Pittis via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Dec 24 11:58:45 PST 2016
I'm posting this in Learn because I'm assuming I've done
something wrong rather than discovered a bug.
Running `dmd -main main.d` with the following 3 files produces
the following linker error.
```
$ dmd -main main.d
Undefined symbols for architecture x86_64:
"_D13linking_fails12__ModuleInfoZ", referenced from:
_D4main12__ModuleInfoZ in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to
see invocation)
Error: linker exited with status 1
```
```
// main.d
import linking_succeeds;
import linking_fails;
```
```
// linking_succeeds.d
import std.range;
```
```
// linking_fails.d
import std.stdio;
```
In the `linking_fails.d` file, if I replace the stdio import with
`import std.algorithm`, running `dmd -main main.d` succeeds.
Somehow stdio is causing the linker to fail.
Any idea what's going on or how to fix it? Thanks!
(DMD64 D Compiler v2.072.0, macOS Sierra 10.12)
More information about the Digitalmars-d-learn
mailing list