Hi all,

I've just installed gdc from Debian Stable (gdc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516), and have been having linker errors when using writeln.

A minimal nonworking example is as follows: I have a file library.d which contains the following:

| module library;
|
| import std.stdio;
|
| class Greeter(string s) {
|
|   this() { }
|
|   void say_hello() {
|     writeln("Hello ", s, "!");
|   }
| }

I also have a file executable.d which contains the following:

| module executable;
| import library;
|
| int main() {
|
|   alias G = Greeter!("James");
|   G a = new G();
|   a.say_hello();
|   return 0;
| }

An attempt to compile it looks as follows:

| $ gdc executable.d -o executable
| /tmp/cc4RjTlb.o:(.data.rel+0x10): undefined reference to `_D7library12__ModuleInfoZ'
| collect2: error: ld returned 1 exit status

If I remove the import std.stdio and the writeln command from library.d, then it all works, so I'm clearly not linking libraries right, but it's not clear to me what to do.

Reply via email to