digitalmars.D.bugs - [Issue 11439] New: Linker error while importing modules in unit test blocks
- d-bugmail puremagic.com (70/70) Nov 04 2013 http://d.puremagic.com/issues/show_bug.cgi?id=11439
http://d.puremagic.com/issues/show_bug.cgi?id=11439 Summary: Linker error while importing modules in unit test blocks Product: D Version: D2 Platform: x86_64 OS/Version: Mac OS X Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: spam kalekold.net --- The test case involves three files: test/methods.d, test/test1.d and test/test2.d. Because this is describing a problem with importing the files need to reside inside a directory, here i've called it 'test'. Source code: test/methods.d: module test.methods; import std.array; public bool nothing(int[] x) { return x.empty(); } test/test1.d: module test.test1; struct S { int x[]; } unittest { import test.methods; import std.stdio; writeln("test1 unit test"); S s; assert(s.x.nothing()); } test/test2.d: module test.test2; import test.test1; struct T { int x[]; } I compile the above sources like this: rdmd --force -de -debug -I~/<dir containing test dir> -m64 -main -property -unittest -w methods.d rdmd --force -de -debug -I~/<dir containing test dir> -m64 -main -property -unittest -w test1.d rdmd --force -de -debug -I~/<dir containing test dir> -m64 -main -property -unittest -w test2.d When i try and compile `test2.d` i get the following error: Undefined symbols for architecture x86_64: "_D4test7methods12__ModuleInfoZ", referenced from: _D4test5test112__ModuleInfoZ in test2.o "_D4test7methods7nothingFAiZb", referenced from: _D4test5test114__unittestL8_1FZv in test2.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) If i add the following to the bottom of `test2.d` it compiles fine but it shouldn't be needed: unittest { import test.methods; } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 04 2013