Thread overview | |||||
---|---|---|---|---|---|
|
November 30, 2012 Linker error | ||||
---|---|---|---|---|
| ||||
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. |
November 30, 2012 Re: Linker error | ||||
---|---|---|---|---|
| ||||
Posted in reply to RenatoUtsch | On Friday, 30 November 2012 at 18:44:31 UTC, RenatoUtsch wrote:
> <skipped>
> $ dmd testReturn.d
> ...
because you didn't compiled the second file.
|
November 30, 2012 Re: Linker error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Maxim Fomin | On Friday, 30 November 2012 at 19:09:12 UTC, Maxim Fomin wrote:
> On Friday, 30 November 2012 at 18:44:31 UTC, RenatoUtsch wrote:
>> <skipped>
>> $ dmd testReturn.d
>> ...
>
> because you didn't compiled the second file.
Man, I was going to say that it didn't work, that I tested it before, but then I noticed that I added classy.widget.d to the command line, not classy/widget.d, it worked.
Sorry for the dumb mistake.
|
Copyright © 1999-2021 by the D Language Foundation