How do I capture all of my compiler's output to a file?

前端 未结 10 2419
無奈伤痛
無奈伤痛 2020-12-23 09:16

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

$CFLAGS=\"-g Wall\" CXXFLAGS=\"-g Wall\" ../trunk/configure --prefix=/some         


        
相关标签:
10条回答
  • 2020-12-23 09:27

    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
    

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

    0 讨论(0)
  • 2020-12-23 09:32

    In C shell - The ampersand is after the greater-than symbol

    make >& filename
    
    0 讨论(0)
  • 2020-12-23 09:32

    It is typically not what you want to do. You want to run your compilation in an editor that has support for reading the output of the compiler and going to the file/line char that has the problems. It works in all editors worth considering. Here is the emacs setup:

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

    0 讨论(0)
  • 2020-12-23 09:33

    The output went to stderr. Use 2> to capture that.

    $make 2> file
    
    0 讨论(0)
  • 2020-12-23 09:39

    Based on an earlier reply by @dmckee

    make | tee makelog.txt
    

    This gives you real-time scrolling output while compiling, and simultaneously write to the makelog.txt file.

    0 讨论(0)
  • 2020-12-23 09:40

    In a bourne shell:

    make > my.log 2>&1

    I.e. > redirects stdout, 2>&1 redirects stderr to the same place as stdout

    0 讨论(0)
提交回复
热议问题