D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 18321 - undefined reference to __ModuleInfoZ depending on whether module is imported directly or indirectly
Summary: undefined reference to __ModuleInfoZ depending on whether module is imported ...
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Mac OS X
: P1 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-28 07:37 UTC by Timothee Cour
Modified: 2022-11-16 04:19 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Timothee Cour 2018-01-28 07:37:45 UTC
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;
   +/

 }

```
Comment 1 Richard (Rikki) Andrew Cattermole 2022-11-16 04:19:47 UTC
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.