Thread overview
-L/SUBSYSTEM:windows Error when using -m64
Aug 10, 2021
Marcone
Aug 10, 2021
Adam D Ruppe
Aug 10, 2021
Marcone
Aug 10, 2021
Adam D Ruppe
Aug 10, 2021
Marcone
Aug 10, 2021
Adam D Ruppe
Aug 10, 2021
Marcone
Aug 11, 2021
Mike Parker
August 10, 2021

How use -L/SUBSYSTEM:windows for hide console in x64 prograns? Becouse if I use -L/SUBSYSTEM:windows and -m64 I get this error:

lld-link: error: undefined symbol: WinMain

> > >

referenced by msvcrt120.lib(msvcrt_stub2.obj):($LN5)
Error: linker exited with status 1

If I delete -L/SUBSYSTEM:windows compile fine.

How can I hide console using -m64?

August 10, 2021
On Tuesday, 10 August 2021 at 18:34:03 UTC, Marcone wrote:
> How can I hide console using -m64?

http://dpldocs.info/experimental-docs/arsd.simpledisplay.html#installation-instructions
August 10, 2021
On Tuesday, 10 August 2021 at 18:36:27 UTC, Adam D Ruppe wrote:
> On Tuesday, 10 August 2021 at 18:34:03 UTC, Marcone wrote:
>> How can I hide console using -m64?
>
> http://dpldocs.info/experimental-docs/arsd.simpledisplay.html#installation-instructions

Hi, do you have some other solution without arsd.simpledisplay? I want only dmd feature.
August 10, 2021
On Tuesday, 10 August 2021 at 18:45:35 UTC, Marcone wrote:
> Hi, do you have some other solution without arsd.simpledisplay? I want only dmd feature.

Did you read the paragraph under the link? That IS a dmd switch. Or a ldc switch. It explains the concept which works with anything.
August 10, 2021
On Tuesday, 10 August 2021 at 18:51:28 UTC, Adam D Ruppe wrote:
> On Tuesday, 10 August 2021 at 18:45:35 UTC, Marcone wrote:
>> Hi, do you have some other solution without arsd.simpledisplay? I want only dmd feature.
>
> Did you read the paragraph under the link? That IS a dmd switch. Or a ldc switch. It explains the concept which works with anything.

Using -Lgdi32.lib -Luser32.lib? Same error.
August 10, 2021
On Tuesday, 10 August 2021 at 18:59:33 UTC, Marcone wrote:
> Using -Lgdi32.lib -Luser32.lib? Same error.

The part after that:

If you want the Windows subsystem too, use -L/subsystem:windows -L/entry:mainCRTStartup.


Pass BOTH -L/subsystem:windows AND -L/entry:mainCRTStartup
August 10, 2021
On Tuesday, 10 August 2021 at 19:01:42 UTC, Adam D Ruppe wrote:
> On Tuesday, 10 August 2021 at 18:59:33 UTC, Marcone wrote:
>> Using -Lgdi32.lib -Luser32.lib? Same error.
>
> The part after that:
>
> If you want the Windows subsystem too, use -L/subsystem:windows -L/entry:mainCRTStartup.
>
>
> Pass BOTH -L/subsystem:windows AND -L/entry:mainCRTStartup

Good! work very well! Thank you!
August 11, 2021
On Tuesday, 10 August 2021 at 19:03:06 UTC, Marcone wrote:
> On Tuesday, 10 August 2021 at 19:01:42 UTC, Adam D Ruppe wrote:
>> On Tuesday, 10 August 2021 at 18:59:33 UTC, Marcone wrote:
>>> Using -Lgdi32.lib -Luser32.lib? Same error.
>>
>> The part after that:
>>
>> If you want the Windows subsystem too, use -L/subsystem:windows -L/entry:mainCRTStartup.
>>
>>
>> Pass BOTH -L/subsystem:windows AND -L/entry:mainCRTStartup
>
> Good! work very well! Thank you!

The difference is because DMD uses different linkers on Windows.

By default, it links 32-bit programs with OPTLINK. That linker only requires the subsystem flag---it will recognize that you have a `main` function.

When compiling with -m32mscoff or -m64, it uses the Microsoft linker. That linker requires that you also specify the program entry function---it always expects `WinMain`, and the `mainCRTStartup` tells it to look for `main` instead.