2

Ive written an exe in c++ that displays a message box when opened, the problem is that when I open the exe the console window also opens. I copied some code that hides it from the code, but it still flashes for half a second. Is there a way to fix this?

Fritiof Rusck
  • 404
  • 1
  • 3
  • 11
  • What OS? If you're on Windows, what compiler? – HolyBlackCat Nov 20 '19 at 07:12
  • The easiest way is probably to create a non-console project. But if you search a little there are compiler and linker flags that will make a Windows UI executable instead of a console executable. Assuming Windows of course. – Some programmer dude Nov 20 '19 at 07:12
  • @HolyBlackCat I use mingw and im running windows – Fritiof Rusck Nov 20 '19 at 07:26
  • Your app started from `main` that's why you are seeing that console window. If you start your app with `WinMain` then the console window won't show up – Asesh Nov 20 '19 at 07:36
  • there are a lot of duplicates: [Compiling a Win32 GUI app (without a console) using MinGW and Eclipse](https://stackoverflow.com/q/7474504/995714), [Win32 programming hiding console window](https://stackoverflow.com/q/622592/995714)... – phuclv Nov 20 '19 at 08:15

2 Answers2

3

If you're on Windows, and use MinGW GCC (or Clang with GCC's libraries), pass -mwindows flag to the linker.

HolyBlackCat
  • 78,603
  • 9
  • 131
  • 207
0

Windows ? I think you are creating a console app, and the console comes with it.

IMHO, there are two possible ways for you to do:

  1. Using a script to start your app, as suggested in Prevent VBscript app from showing Console Window

  2. create a Window App;

Terry Wu
  • 178
  • 9