Raylib: Hide the Console Window on Windows Release Builds

I was finishing a Raylib project last week when I hit something annoying. Windows kept opening a console window in every build, even the release version. The console window is useful for debugging, but looks ugly and unprofessional when releasing software to users. So I found a quick hack to turn it off for release builds on Windows).

The Fix In Brief

To disable the console window in release builds on Windows but keep it in debug builds, copy and paste the following code into one of your source files (e.g., in main.c):

// Disable the console in Windows releases
# if defined(WIN32) && !defined(_DEBUG)
#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
#endif

How it Works

The pragma tells the linker to make this a Windows app instead of a console one. The “/ENTRY:minCRTStartup” part allows you to use the usual main() function instead o f having to write a WinMain(). The code snippet above only activates this on Windows release builds.

Leave a Comment

Your email address will not be published. Required fields are marked *

 


Shopping Cart
Scroll to Top