Question about using SDL on Windows

I’m not sure if this is addressed somewhere in the FAQs or documentation, but when I run the .exe file that Visual Studio generates, it pops a second window in addition to the main program window. As best I can tell, it’s basically a command prompt that has whatever is being sent to STDOUT. Is there any way – Visual Studio project setting or otherwise – to suppress the second window? I was thinking maybe it was a Debug vs Release thing, but even built as Release configuration, it’s still there. :frowning:

Any help would be greatly appreciated!

I’m mostly on Windows using SDL. How I enable the command prompt is:

#if _DEBUG
#pragma comment(linker, “/subsystem:“console” /entry:“WinMainCRTStartup””)
#endif

This is just at the top of my main.cpp. Simply removing this will disable the command prompt from showing up. Not sure if you have this somewhere in your code?From: daveb@webetry.com
Date: Mon, 24 Mar 2014 17:25:41 +0000
To: sdl at lists.libsdl.org
Subject: [SDL] Question about using SDL on Windows

I'm not sure if this is addressed somewhere in the FAQs or documentation, but when I run the .exe file that Visual Studio generates, it pops a second window in addition to the main program window. As best I can tell, it's basically a command prompt that has whatever is being sent to STDOUT. Is there any way -- Visual Studio project setting or otherwise -- to suppress the second window? I was thinking maybe it was a Debug vs Release thing, but even built as Release configuration, it's still there.  

Any help would be greatly appreciated!


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Hi Dave,

it sounds very much like your project setup uses the wrong subsystem
when compiling. Project Properties -> Linker -> SubSystem, change from
Console to Windows.Am 24.03.2014 18:25, schrieb DaveB1980:

I’m not sure if this is addressed somewhere in the FAQs or
documentation, but when I run the .exe file that Visual Studio
generates, it pops a second window in addition to the main program
window. As best I can tell, it’s basically a command prompt that has
whatever is being sent to STDOUT. Is there any way – Visual Studio
project setting or otherwise – to suppress the second window? I was
thinking maybe it was a Debug vs Release thing, but even built as
Release configuration, it’s still there. Sad

Any help would be greatly appreciated!


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Best Regards
Jan Henke
-------------- next part --------------
A non-text attachment was scrubbed…
Name: signature.asc
Type: application/pgp-signature
Size: 899 bytes
Desc: OpenPGP digital signature
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20140324/57b096eb/attachment.pgp

2014-03-24 18:25 GMT+01:00 DaveB1980 :

I’m not sure if this is addressed somewhere in the FAQs or
documentation, but when I run the .exe file that Visual Studio generates,
it pops a second window in addition to the main program window. As best I
can tell, it’s basically a command prompt that has whatever is being sent
to STDOUT. Is there any way – Visual Studio project setting or otherwise
– to suppress the second window? I was thinking maybe it was a Debug vs
Release thing, but even built as Release configuration, it’s still there. [image:
Sad]

Any help would be greatly appreciated!

Does this help?

Martin Grant wrote:

I’m mostly on Windows using SDL. How I enable the command prompt is:

#if _DEBUG
#pragma comment(linker, “/subsystem:“console” /entry:“WinMainCRTStartup””)
#endif

This is just at the top of my main.cpp. Simply removing this will disable the command prompt from showing up. Not sure if you have this somewhere in your code?

Jonas Kulla wrote:

http://stackoverflow.com/questions/2139637/hide-console-of-windows-application (http://stackoverflow.com/questions/2139637/hide-console-of-windows-application)

Does this help??

Thanks for the replies… Neither one fixed the problem, unfortunately. It’s tough because I’m sure I can’t be the only one to encounter this, it’s just tough to know what the right question or keywords to search for on Google are. I end up with a ton of irrelevant results.

Strike my last reply. After doing a “Clean Solution” and rebuilding, the change of subsystem did the trick.

Thanks again!

Message-ID:
Content-Type: text/plain; charset=“iso-8859-1”

I’m mostly on Windows using SDL. How I enable the command prompt is:

#if _DEBUG
#pragma comment(linker, “/subsystem:“console” /entry:“WinMainCRTStartup””)
#endif

This is just at the top of my main.cpp. Simply removing this will disable the
command prompt from showing up. Not sure if you have this somewhere in your
code?

That pragma simply changes whether program INVOCATION is sufficient to
pop-up a console window, by targeting the default subsystem
(presumably gui, but you might be able to configure this) instead of
the console subsystem (and to the best of my knowledge, default
console windo vs no default console window is the only difference
between gui and console: both gui windows and console windows are
available identically in both subsystems). IF I read the OP’s question
right, the console is popping up in response to output that’s being
sent to STDOUT, so I’m not convinced that your fix will be enough. I
think that what’s really needed is stdio redirection, which as I best
recall was REMOVED because some of SDL2’s target platforms make the
only reliable destination for a log file (the directory that the
program is in) read-only, thus preventing any log file from being
written there.

tl:dr; I think the OP should do standard I/O redirection, instead of
playing with the subsystem target.> Date: Mon, 24 Mar 2014 18:27:21 +0000

From: Martin Grant
To: “sdl at lists.libsdl.org
Subject: Re: [SDL] Question about using SDL on Windows

I believe this behavior you describe is caused by the project being compiled with the linker’s subsystem listbox being set to “Console”.On 2014/03/ 24, at 12:25, DaveB1980 wrote:

I’m not sure if this is addressed somewhere in the FAQs or documentation, but when I run the .exe file that Visual Studio generates, it pops a second window in addition to the main program window. As best I can tell, it’s basically a command prompt that has whatever is being sent to STDOUT. Is there any way – Visual Studio project setting or otherwise – to suppress the second window? I was thinking maybe it was a Debug vs Release thing, but even built as Release configuration, it’s still there.

Any help would be greatly appreciated!


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Jeffrey Carpenter
<@Jeffrey_Carpenter>