Linker error

RenatoUtsch renatoutsch at gmail.com
Fri Nov 30 10:44:29 PST 2012


Hello,

I was trying to play with modules and import, but I couldn't 
understand why this code is giving linker errors:

/classy/widget.d
--------------------
module classy.widget;

class ReturnItself
{
	public ref ReturnItself returnItself()
	{
		return this;
	}

	public int returnNumber(in int number)
	{
		return number;
	}
}
--------------------

/testReturn.d
--------------------
import std.stdio, std.conv, classy.widget;

void main()
{
	auto returnItself = new ReturnItself;
	int number = 13;

	writeln(to!string(returnItself.returnItself()
						.returnItself()
						.returnItself()
						.returnItself()
						.returnNumber(number)));
}
--------------------

The linker error is the following:
--------------------
$ dmd testReturn.d
testReturn.o: In function `_Dmain':
testReturn.d:(.text._Dmain+0xa): undefined reference to 
`_D6classy6widget12ReturnItself7__ClassZ'
collect2: error: ld returned 1 exit status
--- errorlevel 1
$
--------------------

I am using Fedora 17, x86_64.


I will be grateful for all help I can get.


More information about the Digitalmars-d-learn mailing list