Hiding console in SDL app

Started by
4 comments, last by Replicon 16 years, 11 months ago
I've taken a long(ish) break from game development, but I'm back at it again. I managed to forget something important, though; in the past I was able to create a Win32 Console app in VS2005 Pro, but was able to create my SDL window with the console in the background hidden. I'm sure there was an option somewhere to turn it off. How do I do that again? Or do I need to create a new normal Win32 non-console app and load my source files into that? Thanks in advance, ukd.
Advertisement
Do not create a Win32 console app. There is an option to turn it off, because I made this mistake myself--however, I don't remember how to make the change. If the project is not big, just recreate it as a Win32 Project that's "empty".

Edit: You can try changing a Linker setting in the Project Properties. On the Linker -> System page, there is a field called "SubSystem", set it to "Windows (/SUBSYSTEM:WINDOWS)".
As indicated by Maxamor you can modify your link settings. Your current link settings probably look something like this:

kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib glut32.lib glu32.lib /nologo /subsystem:console incremental:yes /pdb:"Debug/example.pdb /debug /machine:I386 /out:"Debug/example.exe" /pdbtype:sept

Note the /subsystem:console element. You'll want to change this to the following:

/subsystem:windows /entry:mainCRTStartup

This sets the /subsystem to windows as opposed to console. When this is defined Visual C++ expects to find WinMain() instead of the usual main(). Therefore, if you're using main() then it's necessary to specify the /entry as mainCRTStartup.

Now you have a windows application using the usual main() and no console window.
SDL has its own WinMain function, so you don't need to redirect the entry point.
Awesome, it's working properly now. Thanks everyone!
Hmm I had forgotten to do that, thanks!

Though all I had to do was add "-mwindows" in my link line in my Makefile.

This topic is closed to new replies.

Advertisement