digitalmars.D.learn - Linker error
- RenatoUtsch (44/44) Nov 30 2012 Hello,
- Maxim Fomin (2/5) Nov 30 2012 because you didn't compiled the second file.
- RenatoUtsch (5/10) Nov 30 2012 Man, I was going to say that it didn't work, that I tested it
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.
Nov 30 2012
On Friday, 30 November 2012 at 18:44:31 UTC, RenatoUtsch wrote:<skipped> $ dmd testReturn.d ...because you didn't compiled the second file.
Nov 30 2012
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: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.<skipped> $ dmd testReturn.d ...because you didn't compiled the second file.
Nov 30 2012