Linking C libraries with DMD
bachmeier via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jan 21 17:34:00 PST 2016
On Thursday, 21 January 2016 at 23:07:06 UTC, jmh530 wrote:
> I ran
>
> dmd -m64 <file>.d -L/LIBPATH:<path to lib> -L<library name>
>
> and got
>
> <library name> : fatal error LNK1136: invalid or corrupt file
> --- errorlevel 1136
>
> At least that's progress.
>
> LNK1136 is for a corrupt or abnormally small file. I did notice
> that the original dll was 82kb and the lib file was 2kb.
Have you used pragma(lib)? https://dlang.org/spec/pragma.html#lib
There's also a section on it in Learning D.
I don't use Windows much, but when I link to a dll, that's what I
do. I've actually never used -L options on Windows. If I want to
call functions from R.dll, I use implib /system R.lib R.dll to
create R.lib. Then I put pragma(lib, "R.lib"); in my .d file and
compile.
More information about the Digitalmars-d-learn
mailing list