On Monday, 4 March 2019 at 18:34:09 UTC, Robert M. Münch wrote:
Hi, when compiling a minimal Windows GUI app (using WinMain())
and compiling it with DUB, the 32-bit x86 version is a
character subsystem EXE (writeln works) and for x86_64 it's a
GUI subsystem EXE (writeln doesn't work). Since compiling the
same source, with the same DUB config file, I would expect the
x86 and x86_64 version to be equal.
That's the DUB JSON I use:
{
"targetType" : "executable",
"libs-windows-x86_64": ["user32", "gdi32"],
"libs-windows-x86" : ["gdi32"],
}
So, how can I get a character subsystem for x86_64 and a GUI
subsystem for x86?
I stopped using WinMain with D a long time ago. It's not
necessary. If you always use `main`, then both linkers will
provide you with a console subsystem app by default. That's
particularly useful during development. You can add a
configuration to your dub.json that turns on the windows
subsystem for both linkers.
For OPTLINK (x86) you only need to pass to the linker
`/SUBSYSTEM:windows`.
For the MS linker (x86_mscoff, x86_64) you need to that and you
need to specify that the entry point is `main`, because it will
expect `WinMain` when you specify the windows subsystem. You can
do that with `/ENTRY:mainCRTStartup`
https://docs.microsoft.com/en-us/cpp/build/reference/subsystem-specify-subsystem?view=vs-2017
https://docs.microsoft.com/en-us/cpp/build/reference/entry-entry-point-symbol?view=vs-2017