digitalmars.D.learn - linking with c
- Mike (20/20) Jan 10 2009 So I'm trying to link a C file to be used in a D program:
- Jason House (2/5) Jan 10 2009 I usually keep it simple and do: dmd main.d hw.obj
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?
Jan 10 2009
Mike wrote:So I'm trying to link a C file to be used in a D program: I compile the C file with dmc: dmc -c hw.c and the D file with dmd: dmd -c hw_main.dI usually keep it simple and do: dmd main.d hw.obj
Jan 10 2009