How to redirect the output of gcc compiler to a file?

前端 未结 2 1368
暖寄归人
暖寄归人 2020-12-05 05:33

Redirection operator does not work. So how should we do it? One more question, in makefile, how can we give arguments from command line, like

run: a.out
             


        
2条回答
  •  粉色の甜心
    2020-12-05 05:55

    gcc prints its error messages to stderr, so you have to redirect stderr:

    gcc -o foo foo.c 2> foo.gccmessages
    

    You give arguments on the command line always in the same way

    ./a.out argument1 argument2 argument3
    

提交回复
热议问题