Alex Rivera | Logout

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

Asked 2009-09-29T05:46:52.667
22

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
    ./a.out **<input>**
gcc
Edit
Report

1 Answer

32

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
answered 2009-09-29T05:49:32.843

Your Answer