【问题标题】:gcc error output not getting directed to filegcc 错误输出未定向到文件
【发布时间】:2014-10-01 23:13:46
【问题描述】:

我无法找出为什么 python 构建中的 gcc 进程(尝试从源代码构建 wxPython)没有输出到日志文件。我像这样执行python构建:

python setup.py build > build.log

此安装脚本在其中运行 gcc。消息很丰富,滚动到屏幕外。这就是为什么我将它定向到日志文件的原因。不幸的是,没有记录 gcc 命令之后的任何内容。换句话说,日志文件中的内容是这样的:

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

然后什么都没有。日志就停在这里。我知道还有更多,因为当我在终端运行相同的命令时,我会得到更多的东西,最后会出现“gcc failed with exit code 1”。但是,由于我无法看到 gcc 错误,因为它们会滚动到屏幕外,所以我不知道问题出在哪里。

【问题讨论】:

    标签: python linux gcc wxpython


    【解决方案1】:

    gcc 正在写信给stderr。使用2>&1 > file 将其链接到stdout
    如果您只想重定向stderr,请使用2> file。检查您的 shell 的 man 以获取有关重定向的更多信息。

    【讨论】:

      【解决方案2】:

      也将标准错误输出重定向到 build.log。 重定向语法取决于您使用的 shell。

      对于普通的shbash

      python setup.py build > build.log 2>&1
      

      tcsh:

      python setup.py build >& build.log
      

      【讨论】:

      • 如果我这样做,我会收到几条与 Python 相关的消息,然后是“invalid command name 'build.log'”
      猜你喜欢
      • 1970-01-01
      • 2020-08-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多