[英]gcc makefile dependency wont generate
I have the following simple makefile 我有以下简单的makefile文件
#all: binsem.a ut.a ph
FLAGS = -Wall -L./
binsem.a:
gcc $(FLAGS) -c binsem.c
ar rcu libbinsem.a binsem.o
ranlib libbinsem.a
ut.a:
gcc $(FLAGS) -c ut.c
ar rcu libut.a ut.o
ranlib libut.a
clean:
rm -f *.o
rm -f a.out
rm -f *~
rm -f ph
rm -f *a
The problem is it only generates binsem.a and not ut.a, probably because of dependencies issues. 问题在于它可能仅生成binsem.a而不生成ut.a,这可能是由于依赖性问题所致。
I tried looking at the flags but did not find the answer. 我尝试查看标志,但未找到答案。
Thanks a lot. 非常感谢。
By default, if you don't specify a target on the command line, make
will build the first target it finds (and it's dependencies if it has any). 默认情况下,如果未在命令行上指定目标, make
将构建它找到的第一个目标(如果有,则为依赖项)。 Your first target is binsem.a
, and you don't list any dependencies, so that's the only thing that gets built. 您的第一个目标是binsem.a
,并且没有列出任何依赖项,因此这是唯一要构建的东西。
Try something like adding this at the top: 尝试在顶部添加以下内容:
all: binsem.a ut.a
And mention the dependencies in your other targets: 并提及其他目标中的依赖项:
binsem.a: binsem.c
...
ut.a: ut.c
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.