# How to hide terminal(WIN32\_CONSOLE) window in release build mode?

**URL:** <https://discourse.slicer.org/t/how-to-hide-terminal-win32-console-window-in-release-build-mode/22532>\
**Category:** Development\
**Created:** [March 16, 2022, 3:47am UTC](https://discourse.slicer.org/t/how-to-hide-terminal-win32-console-window-in-release-build-mode/22532 "2022-03-16T03:47:48Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dhaval](https://avatars.discourse-cdn.com/v4/letter/d/85e7bf/32.png) [@Dhaval](https://discourse.slicer.org/u/Dhaval)\
**Post date:** [March 16, 2022, 3:47am UTC](https://discourse.slicer.org/t/how-to-hide-terminal-win32-console-window-in-release-build-mode/22532/1 "2022-03-16T03:47:48Z")

</div>

I build release mode. When i run Slicer, it still have terminal window. How to hide terminal in release build mode?( Windows 10)

Slicer\_BUILD\_WIN32\_CONSOLE = OFF (But the terminal still exists.)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 16, 2022, 7:54pm UTC](https://discourse.slicer.org/t/how-to-hide-terminal-win32-console-window-in-release-build-mode/22532/2 "2022-03-16T19:54:00Z")

</div>

Check out the application options in CMake:

> <https://github.com/Slicer/Slicer/blob/8eaa925245a96cf46d6c2baab72bc7c07b6e3aa3/CMake/SlicerApplicationOptions.cmake#L47-L48>

`Slicer_BUILD_WIN32_CONSOLE` controls if Slicer executable (SlicerApp-real.exe) is a console application or not. You need to turn off `Slicer_BUILD_WIN32_CONSOLE_LAUNCHER` if you don’t want to see the console.

---

<div class="post-metadata">

**Author:** ![zhang\_ming](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zhang_ming/32/15790_2.png) [@zhang\_ming](https://discourse.slicer.org/u/zhang_ming)\
**Post date:** [August 9, 2022, 9:56am UTC](https://discourse.slicer.org/t/how-to-hide-terminal-win32-console-window-in-release-build-mode/22532/3 "2022-08-09T09:56:16Z")

</div>

I set this OFF, then run cmake gui again, but still exeists.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 9, 2022, 10:05am UTC](https://discourse.slicer.org/t/how-to-hide-terminal-win32-console-window-in-release-build-mode/22532/4 "2022-08-09T10:05:26Z")

</div>

Make sure you build ALL\_BUILD target in the top-level Slicer.sln with the correct configuration (Release, Debug,…) and that Slicer.exe is not running (do not use `Slicer.exe --VisualStudio` to start Visual Studio for this build l, just simply open the .sln file by double-clicking on it).

---

<div class="post-metadata">

**Author:** ![zhang\_ming](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zhang_ming/32/15790_2.png) [@zhang\_ming](https://discourse.slicer.org/u/zhang_ming)\
**Post date:** [August 9, 2022, 9:50am UTC](https://discourse.slicer.org/t/how-to-hide-terminal-win32-console-window-in-release-build-mode/22532/5 "2022-08-09T09:50:12Z")

</div>

#-----------------------------------------------------------------------------

# Terminal support

#-----------------------------------------------------------------------------  
if(WIN32)  
option(Slicer\_BUILD\_WIN32\_CONSOLE “Build ${PROJECT\_NAME} executable as a console app on windows (allows capturing console output)” OFF)  
option(Slicer\_BUILD\_WIN32\_CONSOLE\_LAUNCHER “Build ${PROJECT\_NAME} launcher executable as a console app on windows (displays console at application start)” OFF)

and I have turned off the option

---

<div class="post-metadata">

**Author:** ![zhang\_ming](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zhang_ming/32/15790_2.png) [@zhang\_ming](https://discourse.slicer.org/u/zhang_ming)\
**Post date:** [August 9, 2022, 1:03pm UTC](https://discourse.slicer.org/t/how-to-hide-terminal-win32-console-window-in-release-build-mode/22532/6 "2022-08-09T13:03:53Z")

</div>

I’m realllly sure, I make the this code to turn off console:

[Slicer/SlicerApplicationOptions.cmake at 8eaa925245a96cf46d6c2baab72bc7c07b6e3aa3 · Slicer/Slicer (github.com)](https://github.com/Slicer/Slicer/blob/8eaa925245a96cf46d6c2baab72bc7c07b6e3aa3/CMake/SlicerApplicationOptions.cmake#L47-L48)

 ![20220809210011](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/b/3ba3e01443df937a79accc6f350eae1cbfbd559e.png)

and then redo cmake gui operation:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/e/9e7190321a99413ef6f68a68980a96201b0dfc94.png)

then follow the steps:  
configure  
generate  
open sln  
package

but still can’t hide console

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [August 9, 2022, 1:09pm UTC](https://discourse.slicer.org/t/how-to-hide-terminal-win32-console-window-in-release-build-mode/22532/7 "2022-08-09T13:09:58Z")

</div>

I’m not entirely sure if you can do an incremental build to update from having console ON to then having it be OFF. You could always try a completely fresh build with the appropriate configuration set to OFF and then build.

---

<div class="post-metadata">

**Author:** ![zhang\_ming](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zhang_ming/32/15790_2.png) [@zhang\_ming](https://discourse.slicer.org/u/zhang_ming)\
**Post date:** [August 9, 2022, 1:55pm UTC](https://discourse.slicer.org/t/how-to-hide-terminal-win32-console-window-in-release-build-mode/22532/8 "2022-08-09T13:55:55Z")

</div>

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/8/78115dc5f60257bbecaf67e62f1698a962f5f235.png)  
I found the flag Slicer\_BUILD\_QTLOADABLEMODULES everywhere even in **Release** folder ,to change the value of default **ON** to **OFF**. then clean and rebuild this, failed. still console appeared, what a shame, so I will try build from scratch , thank you

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [August 9, 2022, 2:10pm UTC](https://discourse.slicer.org/t/how-to-hide-terminal-win32-console-window-in-release-build-mode/22532/9 "2022-08-09T14:10:50Z")

</div>

My experience is that this flag only applies for installed packages. While you run Slicer from your build tree you will see the console. However, if you generate a package and install it, the console does not appear if you had the flag off when building.

---

<div class="post-metadata">

**Author:** ![zhang\_ming](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zhang_ming/32/15790_2.png) [@zhang\_ming](https://discourse.slicer.org/u/zhang_ming)\
**Post date:** [August 9, 2022, 2:23pm UTC](https://discourse.slicer.org/t/how-to-hide-terminal-win32-console-window-in-release-build-mode/22532/10 "2022-08-09T14:23:54Z")

</div>

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/4/f414f2780f2052da89d650a517b1b2a305935199.png)

should this be True?

---

<div class="post-metadata">

**Author:** ![zhang\_ming](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zhang_ming/32/15790_2.png) [@zhang\_ming](https://discourse.slicer.org/u/zhang_ming)\
**Post date:** [August 9, 2022, 10:56pm UTC](https://discourse.slicer.org/t/how-to-hide-terminal-win32-console-window-in-release-build-mode/22532/11 "2022-08-09T22:56:43Z")

</div>

@lassoan I build from scratch, and even set this two args False, but the release version still have the console window. I’m wondering something in detail the docs may ignored to describe?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 11, 2022, 8:11pm UTC](https://discourse.slicer.org/t/how-to-hide-terminal-win32-console-window-in-release-build-mode/22532/12 "2022-08-11T20:11:25Z")

</div>

> [@cpinter](#):
>
> My experience is that this flag only applies for installed packages. While you run Slicer from your build tree you will see the console.

I’ve checked the [implementation](https://github.com/Slicer/Slicer/blob/da82798ad4fbcddd38e4dcb883ce9cf37615cc79/CMake/SlicerMacroBuildApplication.cmake#L688-L716) and this is indeed the case. `c:\D\S4R\Slicer-build\Slicer.exe` is always a console application. This is useful for development, as you can see the process output while you are running Slicer or tests.

If you set `Slicer_BUILD_WIN32_CONSOLE_LAUNCHER` variable to `OFF` in CMake, then configure, generate, build the project, and then build the `PACKAGE` target, then `Slicer.exe` in the install package will be created by copying `c:\D\S4R\CTKAPPLAUNCHER\bin\CTKAppLauncherW.exe` (while the flag is `ON` then the `c:\D\S4R\CTKAPPLAUNCHER\bin\CTKAppLauncher.exe` file is copied).

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [August 11, 2022, 8:37pm UTC](https://discourse.slicer.org/t/how-to-hide-terminal-win32-console-window-in-release-build-mode/22532/13 "2022-08-11T20:37:37Z")

</div>

Then if there’s a need you should be able to easily switch between launcher types by just copying and renaming the executables with no rebuild required.
