[英]makefile generate file object for the header file only?
im having probleme in makefile
. 我在makefile
。 when i execute make
commande in the terminal it has to generate header.o
and main.o
and then combine them to generate the excutable kmeans.o
file,but it did not, it only generate header.o
which is km.o
and stop without any error message. 当我在终端中执行make
commande时,它必须生成header.o
和main.o
,然后将它们组合以生成可执行的kmeans.o
文件,但没有,它仅生成header.o
即km.o
并停止没有任何错误信息。
CFLAGS = -ggdb
DEFINES = -DDEBUGGA
INCLUDES =
LIBS = -lstdc++
EXAMPLE = kmeans.o
CC=g++
.cpp.o:
$(CC) -c $(CFLAGS) $(DEFINES) $(INCLUDES) $<
all:: km.o kmeans.o
km.o: km.cpp km.hpp
gnuplot_i.o: gnuplot_i.hpp
kmeans.o: main.cpp
kmeans: $(EXAMPLE)
$(CC) -o $@ $(CFLAGS) $(EXAMPLE) $(LIBS)
clean:
rm -f $(EXAMPLE) kmeans
The km.cpp
and km.hpp
is the header file and it implementation. km.cpp
和km.hpp
是头文件及其实现。 gnuplot_i.hpp
is header with its implementation. gnuplot_i.hpp
是其实现的标头。 main.cpp
file the file which links all these libries. main.cpp
文件链接所有这些库的文件。
The default target in this makefile is all: km.o kmeans.o
. 此makefile中的默认目标是all: km.o kmeans.o
。
So when you run make
that is what will run. 因此,当您运行make
,它将运行。 So make will create those two .o
files and stop. 因此,make将创建这两个.o
文件并停止。
If you want make
to be the same as make kmeans
then you need all: kmeans
as your default rule or to move the kmeans
target above the all
target (since the first target is the default one). 如果要使make
与make kmeans
相同,则需要all: kmeans
作为默认规则,或将kmeans
目标移至all
目标之上(因为第一个目标是默认目标)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.