Linker error: Symbol Undefined

Namespace rswhite4 at googlemail.com
Fri Oct 11 11:39:39 PDT 2013


Hey, I'm curious about this linker error:

OPTLINK (R) for Win32  Release 8.00.13
Copyright (C) Digital Mars 1989-2010  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
bar.obj(bar)
  Error 42: Symbol Undefined _D3foo1A6__dtorMFZv
--- errorlevel 1

foo.d:
----
debug import std.stdio;

struct A {
public:
	int id;

	this(int id) {
		debug writeln("CTor A with ", id);

		this.id = id;
	}

	debug ~this() {
		writeln("DTor A with ", id);
	}
}
----

bar.d
----
import foo;

void test(A a) {
	a.id++;
}

void main() {
	test(A(42));
	A a = A(23);
	test(a);
}
----

Usage:

C:\Users\Besitzer\Desktop>dmd -lib foo.d

C:\Users\Besitzer\Desktop>dmd bar.d foo.lib -debug
OPTLINK (R) for Win32  Release 8.00.13
Copyright (C) Digital Mars 1989-2010  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
bar.obj(bar)
  Error 42: Symbol Undefined _D3foo1A6__dtorMFZv
--- errorlevel 1

====
Without -debug or with 'debug' _in_ the DTor (before writeln) 
instead before the DTor works fine.


More information about the Digitalmars-d-learn mailing list