tags:

views:

1759

answers:

4

I am redirecting the g++ compiler output(both stderr and stdout) to a file on linux. But it is creating an empty file.

I read in some other post that stdout is not flushed after every line. Thats ok, but what about stderr. In my case there are compilation errors running several screens. So, I am interested in stderr output. There is no stdout output created.

 g++ -c -I ~/cplusplus/boost_1_37_0/boost_1_37_0/ -I 
~/cplusplus/niVxWorksDeliver/TEES/ Algorithms.cpp 2> output

The above command creates an empty file named "output". The following command reports invalid null command.

 g++ -c -I ~/cplusplus/boost_1_37_0/boost_1_37_0/ -I    
~/cplusplus/niVxWorksDeliver/TEES/ Algorithms.cpp &> output
Invalid null command.
A: 

Here.

dirkgently
A: 

"No news is good news" -- does your command even produce any output? When there are no errors, g++ won't print out anything!

Ferdinand Beyer
i am concerned about stderr. i know that compilation of a file doesnt produce any output :)
rboorgapally
Oh, you are right, I missed that. Sorry!
Ferdinand Beyer
+3  A: 

You might try this:

sh/bash/zsh version:

g++ -c -I ~/cplusplus/boost_1_37_0/boost_1_37_0/ \
       -I ~/cplusplus/niVxWorksDeliver/TEES/ \
       Algorithms.cpp > output 2>&1

csh or tcsh version:

g++ -c -I ~/cplusplus/boost_1_37_0/boost_1_37_0/ \
       -I ~/cplusplus/niVxWorksDeliver/TEES/ \
       Algorithms.cpp >& output
m0j0
rboorgapally
Your shell is not bash. That is a csh error message.
Rob Kennedy
+4  A: 
Rob Kennedy
i am sorry for misleading you. That was only due to my ignorance. Thank you very much.
rboorgapally