How to hide terminal(WIN32_CONSOLE) window in release build mode?

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.)

1 Like

Check out the application options in CMake:

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.

3 Likes

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

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).

1 Like

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

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

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

Slicer/SlicerApplicationOptions.cmake at 8eaa925245a96cf46d6c2baab72bc7c07b6e3aa3 · Slicer/Slicer (github.com)

20220809210011

and then redo cmake gui operation:
image

then follow the steps:
configure
generate
open sln
package

but still can’t hide console

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.

image
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

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.

1 Like

image

should this be True?

@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?

I’ve checked the implementation 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).

1 Like

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.