On Thursday, 1 October 2020 at 20:28:58 UTC, kinke wrote:
On Thursday, 1 October 2020 at 20:03:19 UTC, WhatMeWorry wrote:
Yes, but shouldn't the /NOENTRY option take care of that. Say, I just want to make a DLL of simple functions.

Your little example has 2 problems, the first being an incompatible extern(D) ex/import (mydll.myAddSeven vs. user.myAddSeven) and the second being an incomplete/wrong linker cmdline. When changing the myAddSeven declarations to extern(C++) (another option being a mydll.di header for the import), it works with

dmd -m64 -shared -L/NOENTRY mydll.d
dmd -m64 user.d mydll.lib

For more details, see also https://wiki.dlang.org/Win32_DLLs_in_D.


Thanks all. I've gotten it to work with:

dmd -m64 -ofmydll.dll  mydll.d  -L/NOENTRY -L/DLL

dmd -m64 user.d mydll.lib

user.exe
total = 12


But then I got cocky and decided to just added a writeln() in the mydll.d file and I've been fighting this link error ever since:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\Hostx64\x64\link.exe /NOLOGO "mydll.obj" /OUT:"mydll.dll" /DEFAULTLIB:phobos64 /NOENTRY /DLL /OPT:NOICF /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\lib\x64" legacy_stdio_definitions.lib /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\ucrt\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64"
   Creating library mydll.lib and object mydll.exp
mydll.obj : error LNK2019: unresolved external symbol fwrite referenced in function _D3std5stdio__T13trustedFwriteTaZQsFNbNiNePOS4core4stdcQBx6_iobufxAaZm phobos64.lib(object_72_81a.obj) : error LNK2001: unresolved external symbol memcpy phobos64.lib(exception_cf4_fff.obj) : error LNK2001: unresolved external symbol memcpy phobos64.lib(bits_23fa_21c.obj) : error LNK2001: unresolved external symbol memcpy phobos64.lib(gc_2413_a4e.obj) : error LNK2001: unresolved external symbol memcpy phobos64.lib(gc_2415_a03.obj) : error LNK2001: unresolved external symbol memcpy phobos64.lib(gc_2478_432.obj) : error LNK2001: unresolved external symbol memcpy
  o  o  o

  • Trying to create a tri... WhatMeWorry via Digitalmars-d-learn
    • Re: Trying to cre... Ferhat Kurtulmuş via Digitalmars-d-learn
      • Re: Trying to... user1234 via Digitalmars-d-learn
        • Re: Tryin... WhatMeWorry via Digitalmars-d-learn
          • Re: T... kinke via Digitalmars-d-learn
            • ... WhatMeWorry via Digitalmars-d-learn
              • ... Ferhat Kurtulmuş via Digitalmars-d-learn
                • ... WhatMeWorry via Digitalmars-d-learn
                • ... Ferhat Kurtulmuş via Digitalmars-d-learn
                • ... Imperatorn via Digitalmars-d-learn
                • ... Ferhat Kurtulmuş via Digitalmars-d-learn
                • ... rikki cattermole via Digitalmars-d-learn
    • Re: Trying to cre... Виталий Фадеев via Digitalmars-d-learn

Reply via email to