linux - "ar"工具允许创建空库

标签 linux compilation binutils unix-ar

如果命令行中指定的某些库不存在,则来自 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/

相关文章:

c - EPIPE block 服务器

c - 在C结构中添加字段时如何提醒开发人员访问和查看一些相关函数?

c - 使用 cblas 运行程序

c - 如何确定 gcc 默认将哪些命令行选项传递给 ld?

android - 如何在 Linux 机器上为 Android 构建 linux 命令

c++ - 为armhf编译Crypto++进行交叉编译

javascript - Node ,如何终止/停止 Node 进程? Ubuntu 16.04 长期支持版

python - 如何编译使用 python 3.8 的 PyQt5 程序

linux - 从可执行文件中剥离除指定调试信息之外的所有信息

global-variables - 如何从目标文件中获取全局变量的初始化值?