digitalmars.D - Simple program fails to link - what am I doing wrong?
- Mike Hearn <mike plan99.net> Nov 12 2009
- "Denis Koroskin" <2korden gmail.com> Nov 12 2009
- "Denis Koroskin" <2korden gmail.com> Nov 12 2009
I have a feeling this is a real simple problem. What does _D4test7MyClass1bMFZv
demangle to?
class MyClass {
int a;
void b();
}
int main() {
MyClass c;
return 0;
}
$ dmd -v -run test.d
parse test
importall test
import object (/home/hearn/d/dmd2/linux/bin/../../src/druntime/import/object.di)
semantic test
semantic2 test
semantic3 test
code test
function main
gcc test.o -o test -m32 -Xlinker -L/home/hearn/d/dmd2/linux/bin/../lib
-lphobos2 -lpthread -lm
test.o:(.rodata+0x34): undefined reference to `_D4test7MyClass1bMFZv'
collect2: ld returned 1 exit status
--- errorlevel 1
Nov 12 2009
On Thu, 12 Nov 2009 20:22:56 +0300, Mike Hearn <mike plan99.net> wrote:I have a feeling this is a real simple problem. What does _D4test7MyClass1bMFZv demangle to? class MyClass { int a; void b(); } int main() { MyClass c; return 0; } $ dmd -v -run test.d parse test importall test import object (/home/hearn/d/dmd2/linux/bin/../../src/druntime/import/object.di) semantic test semantic2 test semantic3 test code test function main gcc test.o -o test -m32 -Xlinker -L/home/hearn/d/dmd2/linux/bin/../lib -lphobos2 -lpthread -lm test.o:(.rodata+0x34): undefined reference to `_D4test7MyClass1bMFZv' collect2: ld returned 1 exit status --- errorlevel 1
Function MyClass.b is not implemented (but is referenced, because it is put into a virtual function table).
Nov 12 2009
On Thu, 12 Nov 2009 20:22:56 +0300, Mike Hearn <mike plan99.net> wrote:I have a feeling this is a real simple problem. What does _D4test7MyClass1bMFZv demangle to? class MyClass { int a; void b(); } int main() { MyClass c; return 0; } $ dmd -v -run test.d parse test importall test import object (/home/hearn/d/dmd2/linux/bin/../../src/druntime/import/object.di) semantic test semantic2 test semantic3 test code test function main gcc test.o -o test -m32 -Xlinker -L/home/hearn/d/dmd2/linux/bin/../lib -lphobos2 -lpthread -lm test.o:(.rodata+0x34): undefined reference to `_D4test7MyClass1bMFZv' collect2: ld returned 1 exit status --- errorlevel 1
BTW, questions like this belong to D.learn
Nov 12 2009









"Denis Koroskin" <2korden gmail.com> 