dmd -oftest3 -version=B main.d #ok dmd -oftest3 -version=A main.d Undefined symbols for architecture x86_64: "_D4foo24util12__ModuleInfoZ", referenced from: _D4main12__ModuleInfoZ in test3.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) ```d module main; version(A) import foo2.util; version(B) import foo2.util2; void main(){fun;} module foo2.util2; public import foo2.util; module foo2.util; void fun()(){ // these cause the link error import std.path; //import std.file; /+ // these are ok import std.stdio; import std.range; import std.algorithm; +/ } ```
Not a bug. You did not compile in the other modules into your binary. For small projects you can use -i to automatically compile in the other modules.