www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22651] New: undefined reference to ModuleInfo when using


          Issue ID: 22651
           Summary: undefined reference to ModuleInfo when using imported
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: tim.dlang t-online.de

Compiling the following files with dmd nightly results in a linker error:

///////////////////// a.d /////////////////////
import c;
import std;

imported!q{b}.C obj;

void main()
    Appender!string appender;
    std.file.write("test.txt", appender.data);
///////////////////// b.d /////////////////////
import c;
class C
///////////////////// c.d /////////////////////
import std;

Compiling it with dmd a.d b.d c.d produces the following output:
/usr/bin/ld: a.o:(.data.rel.ro+0x50): undefined reference to
collect2: error: ld returned 1 exit status
Error: linker exited with status 1

The error goes away if a custom definition of imported is used.

dmd nightly has to be used, because imported is not available with dmd 2.098.1.

Jan 04 2022