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;
}
Comment #1 by or — 2016-01-02T11:32:47Z
Anyone has any idea about this one? I experience something similar
Comment #2 by robert.schadek — 2024-12-13T18:13:38Z