One of the things I find nice about CodeBlocks is that it allows me to quickly create, compile and run a file without creating a project. However, this means that all of my programs have console windows, something that isn't normal for most Windows applications.
To get rid of it, I've always had to create a project, throw my file in, and navigate to where I could just click GUI Application instead of Console Application.
However, it's obviously possible to specify the same thing when building using g++.exe and ld.exe, and CodeBlocks has a section for additional linker options, so I figured I could stick it in there to avoid the hassle of always creating a project, but apparently I was wrong.
Firstly, I found this question. I was surprised when I found out who answered it, but that doesn't help me, as the whole point of this is that I can do it with about the same amount of effort without creating a project.
Apparently, the -mwindows
compiler option will do that, so I tried putting that in Settings\Compiler and Debugger\Compiler settings\Other options
, and it compiles and links fine, but still has a console window.
Next, I tried Settings\Compiler and Debugger\Linker settings\Other linker options
. Fuelled by Google results, I've tried adding the following to there, one option active at a time, and rebuilding. Having -mwindows
active makes no difference as far as I can tell.
-Wl: Unrecognized command line option
--subsystem,windows: Unrecognized command line option
--subsystem, windows: windows - No such file or directory.
--subsystem windows: windows - No such file or directory.
--subsystem=windows: Unregocnized command line option
--subsystem, console: console - No such file or directory.
This testing was all done on the newest release of CodeBlocks, CodeBlocks 12.11, and GCC 4.7.2, obtained from this MinGW distro (version 9.4). However, I'm fairly certain it works the same way with CodeBlocks 10.05.
Am I forced to use a project, use a makefile, or build it from the command line, or is it possible to change this setting right in the CodeBlocks IDE global settings?
Passing -Wl,--subsystem,windows
to the linker is the proper way to do this. If it appears not to work then make sure that you didn't insert a space somewhere; use the argument as it is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With