【问题标题】:"ar" tool allows creation of an empty library“ar”工具允许创建一个空库
【发布时间】:2018-01-12 06:14:34
【问题描述】:

如果命令行中指定的某些库不存在,来自 Binutils 的经典“ar”工具不会失败。 它只显示消息“ar: <_library_name_>.a: No such file or directory”,但返回码为零。
这有时使得分析构建问题变得非常困难,因为需要花费大量时间来查找生成的二进制文件中缺少某些函数的原因。

为什么会有这样的行为?真的大多数 Linux 用户都认为正确吗?为什么不添加至少一个失败的选项?

ar -V
GNU ar (GNU Binutils for Ubuntu) 2.24

【问题讨论】:

    标签: linux compilation binutils unix-ar


    【解决方案1】:

    为我工作:

    $ ar unknown.a 2>/dev/null || echo 'ko'
    ko
    
    $ ar -V
    GNU ar (GNU Binutils) 2.28.0.20170506
    Copyright (C) 2017 Free Software Foundation, Inc.
    This program is free software; you may redistribute it under the terms of
    the GNU General Public License version 3 or (at your option) any later version.
    This program has absolutely no warranty.
    

    可能你的ar 版本太旧了。

    【讨论】:

    • 可能,我必须详细说明复制条件。我这样运行命令: $ ar -r result.a `cat /tmp/00000000.lnk_11310` cat: /tmp/00000000.lnk_11310: 没有这样的文件或目录 ar: Creating result.a $ cat result.a ! 通常文件 /tmp/00000000.lnk_11310 应该包含 *.o 文件的列表,但是当它变空(由于另一个问题)时,“ar”会生成空库。
    猜你喜欢
    • 2010-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-05
    • 1970-01-01
    • 2012-08-25
    相关资源
    最近更新 更多