0

Why does the windows command prompt open whenever I run my OpenGL program?

Jake Sumrican
  • 23
  • 2
  • 9

2 Answers2

6

This is nothing specific with OpenGL, but with the framework you use. Most likely you're using GLUT, for which the tutorials use the program entry function main. The default subsystem for programs using main (in contrast to WinMain) opens a console window when started. You can get rid of it using the method I showed in https://stackoverflow.com/a/6882500/524368


If you're using Visual C++ in the project build linker options set

/SUBSYSTEM:windows
/ENTRY:mainCRTStartup

Or use the following #pragma in the source file with the int main(...)

#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")

If using a GNU toolchain use the following additional linker flags to set the subsystem. No need to change the entry function.

LDFLAGS += --subsystem windows
Community
  • 1
  • 1
datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • When I compile my program, it says: "warning: ignoring pragma comment [-Wunknown-pragmas]" – Jake Sumrican Apr 13 '13 at 19:13
  • @JakeSumrican: Let me guess: You're not using Visual C++? Sorry, I should have added, that the instructions were specific to Microsoft's toolchain. In case you're using a GNU toolchain you must use linker options. See my answer update, I'll add in a moment. – datenwolf Apr 13 '13 at 19:16
0

This is a Visual Studio linker configuration setting that can be modified.

In order to disable the console window from appearing during your application's run-time, do the following:

  1. Right-click the project
  2. Go to Properties -> Linker -> System ->SubSystem setting
  3. Ensure that "Windows" is selected and not "Console".
Iswanto San
  • 18,263
  • 13
  • 58
  • 79