Search code examples
pythonlinuxgccwxpython

gcc error output not getting directed to file


I am having trouble finding out why a gcc process inside a python build (trying to build wxPython from source) is not outputting to a log file. I execute the python build like this:

python setup.py build > build.log

This setup script runs gcc inside of it. The messages are copious and scroll off the screen. That is why I have it directed to a log file. Unfortunately, nothing past the gcc command is being logged. In other words what is in the log file is this:

Preparing CORE...
Preparing STC...
[etc lots of other python-related messages]
gcc -pthread -fno-strict-aliasing... [etc. very long gcc command]

and then nothing. The log just stops here. I know there is a lot more because when I run the same command at the terminal I get lots more stuff with a "gcc failed with exit code 1" at the end of it. However, since I can't see the gcc errors since they scroll off the screen I don't know what the problem is.


Solution

  • gcc is writing to stderr. Chain it to stdout using 2>&1 > file.
    If you want to redirect only stderr, use 2> file. Check the man of your shell for further information about redirection.