Linking C libraries with DMD

jmh530 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jan 21 09:20:52 PST 2016


On Thursday, 21 January 2016 at 16:57:26 UTC, W.J. wrote:
>
> You need to port the header file to d. i believe there's the 
> htod utility, however I haven't used that yet.
> Then, basically all you have to do is to tell the linker to 
> link against your C .lib.
> Remember that -LC:\folder (for dmd) passes "C:\folder" on to 
> the linker. Assuming the library folder flag for your linker is 
> -L, you'd want to use -L-LC:\folder.

I already ported the header file to d. What I can't get to work 
is linking a dynamic library.

The whole -L-L is definitely not intuitive. The optlink 
documentation doesn't even describe a -L option. Anyway, it 
doesn't give an error when I use a plus so I tried
dmd <file.d> -L-L+C:\folder\
and it still isn't picking it up. I figured I needed to tell the 
linker what the file actually is, so I tried
dmd <file.d> -L-L+C:\folder\ -L-lib+<libfile.lib>
and that (and a variety of variations) gives errors that LIB 
isn't recognized.


More information about the Digitalmars-d-learn mailing list