2017-08-04 55 views
0

如果在命令行中指定的库不存在,Binutils的经典“ar”工具不会失败。 它只显示消息“ar:< _library_name _>。a:没有这样的文件或目录”,但返回码为零。
这使得分析构建问题有时非常困难,因为人们花费大量时间来查找为什么某些函数在生成的二进制文件中缺失。“ar”工具允许创建空的库

为什么这样的行为?真的,大多数Linux用户发现正确的?为什么不添加至少一个失败的选项?

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

回答

0

工作对我来说:

$ 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版本太旧。

+0

也许,我必须详细说明繁殖条件。我运行命令是这样的: $ AR -r result.a \'猫/tmp/00000000.lnk_11310 \' 猫:/tmp/00000000.lnk_11310:没有这样的文件或目录 AR:创建result.a $ cat result.a ! 通常文件/tmp/00000000.lnk_11310应该包含* .o文件的列表,但是当它变为空时(由于另一个问题),那么“ar”会生成空的库。 –