How to remove console for OpenGL app?

Started by
5 comments, last by Drew_Benton 18 years, 10 months ago
I made an OpenGL Game (online poker) and my teammate wants me to get rid of the console window before we make a non-testing release. I have seen a tip on how to do it before and I'm sure it worked the last time I did it (/subsystem:window /entry:main) but now when I do that it crashes in debug mode and release mode. Running it through debug mode it crashes when allocating memory for std::stringstream. I have no idea what line in Release mode it crashes, but it actually creates the first window, but crashes when hiding it and showing the next one. Are there any other ways to get rid of the console window? Thanks.
Advertisement
Here is what I do.

int main(int argc, char** argv)
...

Then in the project properties, under the linker settings, the subsystem should be windows and the entry point should be "mainCRTStartup".
You might also make sure that _WINDOWS is in the list of preprocessor defines.

Works for me.

Slaru
That worked for me. Thank you so much!
ok .. that worked for me too ,under the Debug build mode . However when on release build I am getting the error below :

LIBC.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Release/glutproject7.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

What cause that error ?

...
ps. any suggestions for installer maker software for opengl applications ?


thanks
#pragma comment( linker, "/subsystem:\"windows\" /entry:\"WinMainCRTStartup\"" )
- Will not give you no console and will require a WinMain function

#pragma comment( linker, "/subsystem:\"console\" /entry:\"WinMainCRTStartup\"" )
- Will give you a console and will require a WinMain function

#pragma comment( linker, "/subsystem:\"console\" /entry:\"mainCRTStartup\"" )
- Will give you a console and will require a main function

#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
- Will not give you a console and will require a main function

So see if what you are using matches up here [wink] (For anyone else too that wants to use this)

As for your error with the Release mode, make sure you are using a similar RunTime library for that project version. I.E. If you used MultiThreaded Debug DLL for debug, you need to change it to MultHreaded DLL for release mode, since it is not done autmatically! That and check against all project settings! They are not carried over.
Are those only for MSVC drew?
Quote:Original post by chad_420
Are those only for MSVC drew?


I'm pretty sure they are [sad]. On the pragma directives page on MSDN, it says:
Quote:
Each implementation of C and C++ supports some features unique to its host machine or operating system. Some programs, for instance, need to exercise precise control over the memory areas where data is placed or to control the way certain functions receive parameters. The #pragma directives offer a way for each compiler to offer machine- and operating system-specific features while retaining overall compatibility with the C and C++ languages. Pragmas are machine- or operating system-specific by definition, and are usually different for every compiler.

Pragmas can be used in conditional statements, to provide new preprocessor functionality, or to provide implementation-defined information to the compiler. The Microsoft C and C++ compilers recognize the following pragmas:


However, it would be neat to try them out on other compilers as well, just in case [wink]

This topic is closed to new replies.

Advertisement