Reputation: 5
When a language gets processed into displaying its output, specifically for compiled languages, their code is compiled by a compiler, assembled by an assembler and linked by a linker to create the executable file.
Since the linker is usually the one making the executable, I assumed that it was the one doing the graphical layout of the console window which is what an exe uses to display output, but when I read more about linkers, It never mentioned about creating a console window at some point after or before linking, So it just got me wondering, which one makes the graphical layout of the console window of an executable binary?
Upvotes: -1
Views: 69
Reputation: 979
The console window is built in into one of the system services of Windows - that's why all programs have the same console. Before Vista, it was located in csrss.exe
. Starting from Vista, it was moved into conhost.exe
. Those programs are automatically launched by Windows when the console is required.
Windows will create a console when:
The last one is indeed controlled by the linker. If you are using Microsoft Linker (link.exe
), you can select a subsystem with /SUBSYSTEM
command line parameter:
/SUBSYSTEM:CONSOLE
will automatically create a console, when EXE is loaded./SUBSYSTEM:WINDOWS
will not create a console (but your program can still create it later with AllocConsole
)/SUBSYSTEM
option - the linker will decide automatically. If your program has a function called main
or wmain
- it will set it to CONSOLE
. If you have WinMain
or wWinMain
instead - it will set WINDOWS
.Upvotes: 2