Redirect Error Messages Output To File
Andi Hellmund
andi@mail.lxgcc.net
Sun Jul 24 17:18:00 GMT 2011
Hi,
> Hi,
>
> Is it possible to redirect the error messages gcc generates to a file and
> not to the console?
> And if yes, how do I do it ?
> (tried g++ main.cpp> out.txt, but this just creates an empty file)
>
> Thank you.
>
this question is not specific to gcc, but to any Linux/UNIX environment.
The error messages are printed to 'stderr' and not 'stdout'. Assuming
BASH, you could redirect the error messages by
g++ main.cpp > out.txt 2> err.txt
> redirects 'stdout'
2> redirects 'stderr'
Andi
More information about the Gcc-help
mailing list