如何将编译器的所有输出捕获到文件中? [英] How do I capture all of my compiler's output to a file?

查看:39
本文介绍了如何将编译器的所有输出捕获到文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 Linux 中从源代码 (CPP) 构建一个开源项目.这是顺序:

I'm building an opensource project from source (CPP) in Linux. This is the order:

$CFLAGS="-g Wall" CXXFLAGS="-g Wall" ../trunk/configure --prefix=/somepath/ --host=i386-pc --target=i386-pc
$make

在编译时,我收到很多编译器警告.我想开始修复它们.我的问题是如何捕获文件中的所有编译器输出?

While compiling I'm getting lot of compiler warnings. I want to start fixing them. My question is how to capture all the compiler output in a file?

<代码>$make >文件 没有做这项工作.它只是保存编译器命令,如 g++ -someoptions/asdf/xyz.cpp 我想要这些命令执行的输出.

$make > file is not doing the job. It's just saving the compiler command like g++ -someoptions /asdf/xyz.cpp I want the output of these command executions.

推荐答案

编译器警告发生在 stderr,而不是 stdout,这就是你看不到它们的原因当您将 make 重定向到其他地方时.相反,如果您使用的是 Bash,请尝试以下操作:

The compiler warnings happen on stderr, not stdout, which is why you don't see them when you just redirect make somewhere else. Instead, try this if you're using Bash:

$ make &> results.txt

& 的意思是将标准输出和标准错误重定向到这个位置".其他 shell 通常具有类似的构造.

The & means "redirect stdout and stderr to this location". Other shells often have similar constructs.

这篇关于如何将编译器的所有输出捕获到文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆