I've set up a trivial test to link D code with C, but I'm running into linker problems.
// Compiled with "gcc -c CTest.c."
void SayHello()
{
printf("%s", "Hello, world!");
}
// Compiled with "dmd DTest.d CTest.o."
extern (C) void SayHello();
void main()
{
SayHello();
}
ld
spits out:
ld: warning: in CTest.o, file was built for unsupported file format which is not the architecture being linked (i386)
Undefined symbols:
"_SayHello", referenced from:
__Dmain in DTest.o
ld: symbol(s) not found
I've tried manually specifying CTest.c
's architecture with -m32 -march=i386
, but that gives me a bus error at runtime. I've never gotten a bus error before, so that just goes right over my head.
What am I doing incorrectly?