Under Visual C++, I have played around with Glut/FreeGlut/GLFW. It seems that everyone of these projects adds a CMD window by default. I tried removing it going under:
When I've gotten an error like that I was able to fix it by entering that following text in the linker, section Advance, option Entry Point the following:
main
To get rid of the console using cmake, the link flags can be set as follows:
set_target_properties(exe_name PROPERTIES
LINK_FLAGS "/ENTRY:mainCRTStartup /SUBSYSTEM:WINDOWS")
If you create a new project as a console application, it will always run as such. You have to create a new GUI project if you want to run it in an actual window, otherwise the correct headers and libraries will not be included.
Also the WinMain function that's required will be included for you in the resulting template files.
Non-console Windows applications use the WinMain()
entry point convention. Your Glut examples probably use the standard C main()
convention.
If you want a quick fix just for the demo app, the WinAPI function FreeConsole()
might help.
MSDN: http://msdn.microsoft.com/en-us/library/ms683150(v=vs.85).aspx
You need to write a WinMain
entry point and copy your existing code (from main
):
int CALLBACK WinMain(
__in HINSTANCE hInstance,
__in HINSTANCE hPrevInstance,
__in LPSTR lpCmdLine,
__in int nCmdShow
){
// ...
}
Under the linker options, set your entry point to mainCRTStartup . This function does the necessary setup of the MS libc and then calls main.