Windows 7 x64. Prevent appearing of console with GUI application

Mike Parker aldacron at gmail.com
Tue Jul 24 09:20:22 UTC 2018


On Tuesday, 24 July 2018 at 08:09:33 UTC, ANtlord wrote:
> Hello! I'm trying run my GUI application getting a console 
> hidden. The application is on top of GTKD, compiled with dmd 
> 2.081.1 in Windows 7 x64. I read a few threads on the forum and 
> StackOverflow and I got that I need to add a module definition 
> file [1] or to add -L/SUBSYSTEM:WINDOWS -L/ENTRY:mainCRTStartup 
> options to compiler [2] or to add only /SUBSYSTEM:WINDOWS [3] 
> or use a command getting console hidden [4].


I've never used a module definition file for this. The 
/subsystem:windows switch has always worked for me. When linking 
with OPTLINK, that's all you need. When using the MS linker, 
you'll need that along with the /ENTRY:mainCRTStartup. With 
recent versions, if you don't have the MS tools installed, you'll 
get the LLVM linker when using -m64 or -m43mscoff. If that's the 
case, I don't know that it even supports changing the subsystem 
or, if it does, what the syntax looks like. A cursory search 
turns up nothing.

Anyway, if you are using OPTLINK or the MS Linker, try a test 
program without gtkD to make sure it works standalone for you.

```
import core.sys.windows.windows;

void main() {
     MessageBoxA(null, "Look, Ma! No console!", "It works!", 
MB_OK);
}
```

Both of the following command lines work for me.

With OPTLINK:
dmd -L/SUBSYSTEM:windows win.d

With the MS linker:
dmd -m64 -L/SUBSYSTEM:windows -L/ENTRY:mainCRTStartup win.d 
user32.lib




More information about the Digitalmars-d-learn mailing list