Trying to create a trivial 64 bit D Lang DLL on a Windows 10 machine and cant get past linking.
Ferhat Kurtulmuş
aferust at gmail.com
Fri Oct 2 08:07:33 UTC 2020
On Friday, 2 October 2020 at 07:34:03 UTC, WhatMeWorry wrote:
> On Thursday, 1 October 2020 at 21:56:46 UTC, Ferhat Kurtulmuş
> wrote:
>> On Thursday, 1 October 2020 at 21:35:42 UTC, WhatMeWorry wrote:
>>> On Thursday, 1 October 2020 at 20:28:58 UTC, kinke wrote:
>>>> [...]
>>>
>>>
>>> Thanks all. I've gotten it to work with:
>>>
>>>>[...]
>>>
>>>>[...]
>>>
>>>>[...]
>>> total = 12
>>>
>>> [...]
>>
>> 1) try running your commands in Visual Studio Native x64 CMD.
>
> Yes, I've been doing that.
>
>> 2) try link with msvcrt.lib
>
> The only msvcrt.lib I can find on my Windows 10 machine is:
>
> "C:\Windows Kits\10\Lib\10.0.19041.0\um\x64\ntstc_msvcrt.lib"
>
> Also on Microsoft's docs
> https://docs.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features?view=vs-2019 it talks about a ucrt.lib?
Here are the steps I used with success:
in a VCx64 cmd ->
set PATH=%PATH%;D:\dlang\dmd.2.094.0.windows\dmd2\windows\bin64
------------------------
module user;
import std.stdio;
import mydll; // Yes, I imported the dll here
//export { int myAddSeven(int a, int b); }
void main()
{
int total = mydll.myAddSeven(2, 3);
writeln(total);
}
-------------------------
module mydll;
export extern(D) {
int myAddSeven(int a, int b) { return a+b+7; } /* <--
function body */
}
---------------------------
dmd -m64 -ofmydll.dll mydll.d -L/NOENTRY -L/DLL
dmd -m64 user.d mydll.lib
More information about the Digitalmars-d-learn
mailing list