linking with c

Mike sgtmuffles at myrealbox.com
Sat Jan 10 14:01:38 PST 2009


So I'm trying to link a C file to be used in a D program:

hw.c:

#include <stdio.h>

void hw()
{
	printf("Hello, world!");
}


hw_main.d:

module hw_main;

extern (C) void hw();

int main()
{
	hw();
	return 0;
}

I compile the C file with dmc: dmc -c hw.c

and the D file with dmd: dmd -c hw_main.d

I try to link them with the digital mars linker: link hw.obj hw_main.obj

bu it complains about phobos.lib. So I try: link hw.obj hw_main.obj (path)\phobos.lib

and I get a bunch of "symbol undefined" errors. Any advice?


More information about the Digitalmars-d-learn mailing list