Reputation: 2823
i'm trying to compile my code with g++ C++ compiler on Windows and the compiler is returning some errors. Ok, as usual. But it's printing so much errors that the console just goes down to the end and I can't see the first lines of error log. My question is: there are any way to print the error log to an external file so I can read the complete error log?
i.e.
g++ *.h *.cpp > error_log.txt
Upvotes: 4
Views: 6868
Reputation: 155
g++ *.cpp > log_file.txt 2>&1
First the >
allows us to redirect the standard output to the log file. Then by using the 2>&1
we redirect the error output to the standard output. By doing so, we redirect every output to the log_file.txt.
Upvotes: 6
Reputation: 2509
You need to redirect stderr
, but it is shell dependant.
For example on sh
and bash
, you can use:
g++ file 2> error.log
On csh
and tcsh
it would be:
( g++ file ) >& error.log
Upvotes: 8