Hi,

I'm new to D and trying my hands on a few simple things. Being able to build a Windows DLL with betterC enabled is of particular interest to me, as I'd need it for a project that I'd like to do in D.

I'm trying to follow some examples, such as [this](https://wiki.dlang.org/Win32_DLLs_in_D) and [this](https://tekmoji.com/?post=Calling%20D%20(dlang)%20shared%20libs%20from%20Python%20on%20Windows), and they compile without `-betterC`, but fail with link errors when using the switch.

example DLL, or see 2nd link for one without the mixin
```D
//WindowsApp1.d
module WindowsApp1;
import core.sys.windows.windows;
import core.sys.windows.dll;

export extern (C) void main()
{
    import core.stdc.stdio : printf;

    printf("Hello betterC\n");
}
mixin SimpleDllMain;
```

then
```
dmd -m64 -shared -betterC WindowsApp1.d
```

yields error:
```
error LNK2019: unresolved external symbol _D4core3sys7windows3dll18dll_process_attachFPvbZb referenced in function DllMain error LNK2019: unresolved external symbol _D4core3sys7windows3dll18dll_process_detachFPvbZv referenced in function DllMain error LNK2019: unresolved external symbol _D4core3sys7windows3dll17dll_thread_attachFbbZb referenced in function DllMain error LNK2019: unresolved external symbol _D4core3sys7windows3dll17dll_thread_detachFbbZb referenced in function DllMain
```

I'm not a complete beginner to programming, so I'm guessing the linker is missing a library, but as I'm not familiar with D yet, and these are fairly basic examples that I expected to run without a hitch, I'm a bit confused as to what I should be doing. Shouldn't the system modules provide the link targets themselves? Should I add a parameter to include a windows system library?

BtW, I've tried compiling from the command line and from Visual Studio using the visuald extension - I'm assuming the extension makes sure the environment variables are set correctly. When using dmd from the command line, I also tried invoking `dmd2vars64.bat` and `vcvars64.bat` before running dmd.exe to ensure the variables are set. In any case, the build process is successful without `betterC`, so I'm assuming the path/variables are set correctly.
  • betterC DLL in W... Tamas via Digitalmars-d-learn
    • Re: betterC... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
      • Re: bet... Tamas via Digitalmars-d-learn
        • Re:... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
        • Re:... bachmeier via Digitalmars-d-learn
          • ... Tamas via Digitalmars-d-learn
    • Re: betterC... Adam D Ruppe via Digitalmars-d-learn
      • Re: bet... Tamas via Digitalmars-d-learn
        • Re:... Adam D Ruppe via Digitalmars-d-learn
          • ... Tamas via Digitalmars-d-learn
            • ... bachmeier via Digitalmars-d-learn

Reply via email to