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?

For MS linker just pass the linker flag /SUBSYSTEM:CONSOLE for console, or /SUBSYSTEM:WINDOWS for no console, it also detects that by the presence of WinMain(), more about linker[1]

This should do for MS linker

    "lflags-windows-x86_64": ["/SUBSYSTEM:CONSOLE"],
    "lflags-windows-x86_mscoff": ["/SUBSYSTEM:WINDOWS"]

For old optlink x86 it is a bit harder, you need to include special .def file that has instruction for linker, here is an example from dlangui[2], adding it with linker libs should work, probably, or maybe, or...

Ok while I writting this I checked dlangui example[3], so do this with that def file

    "sourceFiles-windows-x86": ["$PACKAGE_DIR/src/win_app.def"],

[1] https://docs.microsoft.com/en-us/cpp/build/reference/subsystem-specify-subsystem?view=vs-2017
[2] https://github.com/buggins/dlangui/blob/master/src/win_app.def
[3] https://github.com/buggins/dlangui/blob/master/examples/example1/dub.json#L14

Reply via email to