0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

黒い画面の非表示 GCCオプション設定

Last updated at Posted at 2021-03-14

__Windows10 + GCC__でコンパイルした、__Qt__や__GTK__などの画面を実行すると、黒い画面(コンソール画面)が表示される。邪魔だ!!

CMakeの場合

GCCオプションで、__"-mwindows"__を付けると、この__黒い画面__が表示されなくなる。
FLAGでも、この方法だと、うまく動かないケースがある。

GCCのリンカーのオプションで、__-Wl,--subsystem,console__があると、この__console__が優先されるようだ。
この__subsystem__は、__console__と__windows__の選択肢があるので、後者を指定する

追加: __add_executable()で、"WIN32"__と指定する__だけ__でも行ける!

CMakeList.txt
set(CMAKE_CXX_FLAGS "-mwindows")
set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} "-Wl,--subsystem,windows")

add_executable(プロジェクト名 WIN32 ${PROJECT_SOURCES})

Rust(rustc)の場合

ソースコードの先頭にマクロを指定する。

main.rs
# ![windows_subsystem = "windows"]

Meson Build systemの場合

__gui_app : True__とすると、ninja__に"-mwindows"__を設定してくれる。

meson.build
project('projectName', 'cpp')
executable('program', 'main.cpp', gui_app : True)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?