[英]There are some way to print error log to an external file using g++ C++ compiler? (C++)
i'm trying to compile my code with g++ C++ compiler on Windows and the compiler is returning some errors. 我正在尝试使用Windows上的g ++ C ++编译器编译我的代码,编译器返回一些错误。 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?
我的问题是:有没有办法将错误日志打印到外部文件,所以我可以读取完整的错误日志?
ie 即
g++ *.h *.cpp > error_log.txt
Thanks! 谢谢!
You need to redirect stderr
, but it is shell dependant. 您需要重定向
stderr
,但它依赖于shell。
For example on sh
and bash
, you can use: 例如,在
sh
和bash
,您可以使用:
g++ file 2> error.log
On csh
and tcsh
it would be: 在
csh
和tcsh
上它将是:
( g++ file ) >& error.log
g++ *.h *.cpp 2> error_log.txt
注意'2'它代表stderr。
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. 然后通过使用
2>&1
我们将错误输出重定向到标准输出。 By doing so, we redirect every output to the log_file.txt. 通过这样做,我们将每个输出重定向到log_file.txt。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.