- 1 year ago
How to hide console window from Windows Gtk C programs compiled with cl
To hide the console window from a Windows Gtk C program compiled with cl
(Microsoft C/C++ Compiler), you can use the linker option -mwindows
. This option tells the linker to create a GUI application instead of a console application, which will prevent the console window from being displayed. Here's an example of how you can compile a Gtk program with cl
and hide the console window:
Make sure you have the necessary Gtk development files installed on your system.
Create a source file for your Gtk program, such as
main.c
, and add your code.Open a command prompt and navigate to the directory containing your source file.
Run the following command to compile the program and hide the console window:
shellcl -o myprogram.exe main.c -mwindows `pkg-config --cflags --libs gtk+-3.0`
This command uses
cl
to compile the source filemain.c
and link against the Gtk library. The-mwindows
option tells the linker to create a GUI application.After successful compilation, you will have an executable file named
myprogram.exe
in the current directory.
When you run myprogram.exe
, it should launch the Gtk application without displaying a console window.
Note that the pkg-config --cflags --libs gtk+-3.0
part of the command is used to retrieve the necessary compilation and linking flags for Gtk. Make sure you have pkg-config
installed on your system, and adjust the Gtk version and library name if necessary.
By using the -mwindows
linker option, you can hide the console window and create a GUI application for your Gtk program compiled with cl
on Windows.