如果命令行中指定的某些库不存在,则来自 Binutils 的经典“ar”工具不会失败。
它仅显示消息“ar: <_library_name_>.a: No such file or directory”,但返回代码为零。
这使得有时很难分析构建问题,因为人们会花费大量时间来查找为什么在生成的二进制文件中缺少某些函数。
为什么会有这样的行为?大多数 Linux 用户真的认为正确吗?为什么不至少添加一个失败选项?
ar -V
GNU ar (GNU Binutils for Ubuntu) 2.24
最佳答案
对我有用:
$ 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
版本太旧。
关于linux - "ar"工具允许创建空库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45504562/