Thread overview
lld-link: error: subsystem must be defined
May 08, 2020
WhatMe Worry
May 09, 2020
Mike Parker
May 09, 2020
kinke
May 08, 2020

This is a beginner's question but how to I get past this?

C:\Users\Kyle\AppData\Local\dub\packages\arsd-official-7.2.0\arsd-official>lld-link terminal.obj

lld-link: error: subsystem must be defined

help mentions this option, but
 /subsystem:<value>      Specify subsystem

Is there a good tutorial for ldc2 because I haven't been able to find anything.
May 09, 2020
On Friday, 8 May 2020 at 21:00:12 UTC, WhatMe Worry wrote:
>
>
> This is a beginner's question but how to I get past this?
>
> C:\Users\Kyle\AppData\Local\dub\packages\arsd-official-7.2.0\arsd-official>lld-link terminal.obj
>
> lld-link: error: subsystem must be defined
>
> help mentions this option, but
>  /subsystem:<value>      Specify subsystem
>
> Is there a good tutorial for ldc2 because I haven't been able to find anything.

No matter the linker one uses (OPTLINK, MS link, lld), there are two "subsystems" for Windows program: Windows and Console. The latter starts with console window, the former does not.

Generally, when using the Windows subsystem, WinMain is required (and in D, DRuntime must be manually initialized). When using the Console subsystem, main is required. OPTLINK, however, will accept main with the Windows subsystem just fine. MS link can be configured with the /ENTRY flag to accept either main or WinMain in either subsystem (e.g., /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup).

So for lld, you'll want /subsystem:windows for no console window or /subsystem:console if you want the console. You can still use main with /subsystem:windows by also passing /entry:main.
May 09, 2020
On Friday, 8 May 2020 at 21:00:12 UTC, WhatMe Worry wrote:
> C:\Users\Kyle\AppData\Local\dub\packages\arsd-official-7.2.0\arsd-official>lld-link terminal.obj
> lld-link: error: subsystem must be defined

This doesn't have anything to do with LDC, but it should just work with `ldc2 terminal.obj`.