开发者

Implicit Rules in Makefile

hi i want to do a Makefi开发者_如何学编程le in linux that will take all the .cpp files in the dir compile them and create one .o file that i can active how i can do it with Implicit Rules

thanks mati


Implicit rules will help you create the object files, but combining them together will have to be done explicitly (as it is something that is rarely done).

OBJ = a.o b.o

big.o : ${OBJ}
    ${LD} -r -o $@ $^


Or maybe you can try following method after properly defined the variables:

.o: .cpp
    $(CPP) -c $(CPPFLAGS) $< -o $@
$(EXECUTABLE): $(OBJ)
    $(CPP) $(LDFLAGS) $^ -o $@
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜