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

前端 未结 10 2420
無奈伤痛
無奈伤痛 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:40

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

    The > character does not redirect the standard error. It's useful when you want to save legitimate output without mucking up a file with error messages. But what if the error messages are what you want to save? This is quite common during troubleshooting. The solution is to use a greater-than sign followed by an ampersand. (This construct works in almost every modern UNIX shell.) It redirects both the standard output and the standard error. For instance:

    $ gcc invinitjig.c >& error-msg
    

    Have a look there, if this helps: another forum

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

    Lots of good answers so far. Here's a frill:

    $ make 2>&1 | tee filetokeepitin.txt 
    

    will let you watch the output scroll past.

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

    Assume you want to hilight warning and error from build ouput:

    make |& grep -E "warning|error"
    
    0 讨论(0)
  • 2020-12-23 09:42

    Try make 2> file. Compiler warnings come out on the standard error stream, not the standard output stream. If my suggestion doesn't work, check your shell manual for how to divert standard error.

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