Thread overview
[Issue 19784] DLL in BetterC mode - Symbol Undefined __acrtused_dll
Mar 31, 2019
kinke@gmx.net
Apr 02, 2019
AlexKotik
Apr 02, 2019
kinke@gmx.net
Apr 03, 2019
AlexKotik
Jun 04, 2022
Walter Bright
Dec 17, 2022
Iain Buclaw
Jan 15, 2023
Walter Bright
Jun 04, 2023
Walter Bright
March 31, 2019
https://issues.dlang.org/show_bug.cgi?id=19784

kinke@gmx.net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kinke@gmx.net

--- Comment #1 from kinke@gmx.net ---
This seems to be specific to the DigitalMars C runtime, see https://digitalmars.com/ctg/acrtused.html. You may have more luck with -m32mscoff or -m64.

--
April 02, 2019
https://issues.dlang.org/show_bug.cgi?id=19784

--- Comment #2 from AlexKotik <relmail@rambler.ru> ---
(In reply to kinke from comment #1)
> This seems to be specific to the DigitalMars C runtime, see https://digitalmars.com/ctg/acrtused.html. You may have more luck with -m32mscoff or -m64.

It doesn't compile with -m32mscoff or -m64 either:

> dmd -of=dll.dll -betterC -m32mscoff dll.d
lld-link.exe: error: subsystem must be defined
Error: linker exited with status 1

> dmd -of=dll.dll -betterC -m64 dll.d
lld-link.exe: error: subsystem must be defined
Error: linker exited with status 1

--
April 02, 2019
https://issues.dlang.org/show_bug.cgi?id=19784

--- Comment #3 from kinke@gmx.net ---
This (linker) error can be gotten rid of with -L=/SUBSYSTEM:CONSOLE.

--
April 03, 2019
https://issues.dlang.org/show_bug.cgi?id=19784

--- Comment #4 from AlexKotik <relmail@rambler.ru> ---
(In reply to kinke from comment #3)
> This (linker) error can be gotten rid of with -L=/SUBSYSTEM:CONSOLE.

I think the better thing to do is /DLL, but still I got these errors:
> dmd -of=dll.dll -betterC -L=/DLL -m32mscoff dll.d
lld-link.exe: error: <root>: undefined symbol: __DllMainCRTStartup@12 lld-link.exe: error: undefined symbol: _MessageBoxA@16
>>> referenced by dll.obj:(_Test@0)

Error: linker exited with status 1

If I do /SUBSYSTEM:CONSOLE I get:
> dmd -of=dll.dll -betterC -L=/SUBSYSTEM:CONSOLE -m32mscoff dll.d
lld-link.exe: error: entry point must be defined
Error: linker exited with status 1

If I add /ENTRY:DllMain to that I get:
> dmd -of=dll.dll -betterC -L=/SUBSYSTEM:CONSOLE -L=/ENTRY:DllMain -m32mscoff dll.d
lld-link.exe: error: undefined symbol: _MessageBoxA@16
>>> referenced by dll.obj:(_Test@0)

Error: linker exited with status 1

--
June 04, 2022
https://issues.dlang.org/show_bug.cgi?id=19784

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |betterC
                 CC|                            |bugzilla@digitalmars.com

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=19784

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--
January 15, 2023
https://issues.dlang.org/show_bug.cgi?id=19784

--- Comment #5 from Walter Bright <bugzilla@digitalmars.com> ---
__acrtused_dll is defined in snn.lib, which should be linked in for win32 DLL builds.

--
June 04, 2023
https://issues.dlang.org/show_bug.cgi?id=19784

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |dll

--