GNU将存档成员作为目标
我在使用。问题在于,在某些计算机上(例如运行MacOS,Solaris),它可以正常工作,即构建库,下一个 make
给出
对'all'all'
>无需完成。
但是,在Linux盒子上不始终重建所有内容。在所有机器上,我都使用GNU。
的示例,
这里有一个源文件 foo.c
和 makefile
foo.c
void foo() {}
makefile
all: libfoo.a
libfoo.a(%.o) : %.o
$(AR) cr $@ $^
libfoo.a: libfoo.a(foo.o)
ranlib libfoo.a
任何人可以确认吗? (或告诉我我做了什么明显的愚蠢错误...?)
在Solaris上运行
theon$ make
gcc -c -o foo.o foo.c
ar cr libfoo foo.o
ranlib libfoo
rm foo.o
theon$ make
make: Nothing to be done for 'all'.
Linux
acker$ make
gcc -c -o foo.o foo.c
ar cr libfoo foo.o
ranlib libfoo
rm foo.o
acker$ make
gcc -c -o foo.o foo.c
ar cr libfoo foo.o
ranlib libfoo
rm foo.o
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
很可能不是您,而是您的GNU/Linux发行版很愚蠢,并将“确定性模式”设置为
ar
的默认行为。这是ar
程序的配置时间选项,以确定其默认为“确定性”或“非确定性”(ar
的历史和正确默认行为)。一些发行版在其版本的ar
版本中设置此配置选项并更改默认行为。这会破坏
make
(以及需要知道对象时间戳的任何其他工具)。如果这是问题,您可以更改
ar
的调用以添加u
选项以再次关闭确定模式:不幸的是,
ar 命令无法理解此选项,因此您需要找到一种仅适用于使用GNU Binutils的方法。
您还应该随意向您的GNU/Linux分发投诉。
Most likely it's not you, it's that your GNU/Linux distribution is stupid and has set "deterministic mode" as the default behavior of
ar
. This is a configure-time option for thear
program, to determine whether it defaults to "deterministic" or "non-deterministic" (the historical and correct default behavior forar
). Some distributions made the ridiculous decision to set this configuration option in their version ofar
, and change the default behavior.This breaks
make
(and any other tool that needs to know the timestamps of objects).If this is the problem, you can change your invocation of
ar
to add theU
option to turn deterministic mode off again:Unfortunately it's likely that the
ar
commands on non-GNU systems won't understand this option so you'll need to find a way to add it only for the ones using GNU binutils.You should also feel free to complain to your GNU/Linux distribution about this.