How can I write all the output of my compiler to a file?

I am creating an open source project from source code (CPP) on Linux. This is the order:

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

During compilation, I get a lot of compiler warnings. I want to start fixing them. My question is how to capture all compiler output to a file?

$make > file does not do the job. This is just saving the compiler command as g++ -someoptions /asdf/xyz.cpp I need the output of these commands.

+49
linux shell g ++ io-redirection makefile
Feb 19 2018-10-19
source share
8 answers

Compiler warnings occur on stderr , not stdout , so you don’t see them when you just redirect make to another location. Try instead if you use Bash:

 $ make &> results.txt 

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

+88
Feb 19 '10 at 15:50
source share
β€” -

In the bourne shell:

make> my.log 2> & 1

those. > redirects stdout, 2> and 1 redirects stderr to the same place as stdout

+20
Feb 19 2018-10-19
source share

There are still a lot of good answers. Here's the frill:

 $ make 2>&1 | tee filetokeepitin.txt 

Allows you to keep track of scrolling output.

+18
Feb 19 '10 at 15:52
source share

The output went to stderr. Use 2> to fix this.

 $make 2> file 
+4
Feb 19 '10 at 15:50
source share

From http://www.oreillynet.com/linux/cmd/cmd.csp?path=g/gcc

Character> does not redirect the standard error. This is useful when you want to keep legitimate output without dropping the error message file. But what if error messages do you want to keep? This is quite common when troubleshooting. The solution is to use a larger sign and then an ampersand. (This build work in almost all modern UNIX shells.) It redirects standard output and standard error. For example:

 $ gcc invinitjig.c >& error-msg 

See if it helps: another forum

+2
Feb 19 2018-10-19
source share

Suppose you want to warn about hilight and an error from the collector:

 make |& grep -E "warning|error" 
+1
Jul 19 '16 at 8:16
source share

Try make 2> file . Compiler warnings are output to the standard error stream, not to the standard output stream. If my suggestion doesn't work, check out the shell guide for how to undo a standard error.

0
Feb 19 2018-10-19
source share

This is usually not what you want to do. You want to start compilation in an editor that has support for reading the compiler output and navigating to a char file / line that has problems. He works in all the editions that are worth considering. Here is the emacs setup:

https://www.gnu.org/software/emacs/manual/html_node/emacs/Compilation.html

0
Dec 04 '16 at 22:24
source share



All Articles