Linking to libraries with D

Jarrod gigantic.midget at gmail.com
Fri Nov 16 04:28:33 PST 2007


Well I know this sounds a rather mundane question to all you code buffs out
there, but I'm wondering how I would use C libraries with D.

I've already somewhat figured it out, but I guess I'm still confused a little
because unlike C, D doesn't have header files, and unlike perl, D doesn't seem
to 'add' your imported modules into your code.

See, what I've done is I've converted the curl C headers to D, which leaves me
with two .d files. Now at first, with my perl experience I expected to be able
to just import the module, and the compiler would include the necessary
'header' code into the finished object. However this is not the case. I had to
compile the 'header' into an object, and then link it. This is all well and
good, but it feels.. rather 'unclean' I guess. I mean I expect I'll be using
curl for multiple applications, so am I going to have to make a static
library, just for my D applications to link to.. another library?

I guess the question I'm getting at is, would there a better way to do this?
Is there a way to make the compiler actually compile and include the code you
import? I would rather not have to make a static library just to use code I'm
importing from another library, but I also don't want to have to manually
build and link the code I'm importing every time either. Am I missing
something here?

Any advice much appreciated,
Jarrod.



More information about the Digitalmars-d mailing list