代码Version1
点击查看代码
hello: main.cpp printhello.cpp fatorial.cpp
g++ -o hello main.cpp printhello.cpp factorial.cpp
代码Version2
点击查看代码
CXX = g++
TARGET = hello
OBJ = main.o printhello.o factorial.o
$(TARGET): $(OBJ)
$(CXX) - o $(TARGET) $(OBJ)
main.o:main.cpp
$(CXX) -c mian.cpp
printhello.o: printhello.cpp
$(CXX) -c printhello.cpp
fatorial.o: fatorial.cpp
$(CXX) -c printhello.cpp
代码Version3
点击查看代码
CXX = g++
TARGET = hello
obj = main.o printhello.o factorial.o
CXXFLAGS = -c -Wall
$(TARGET): $(OBJ)
$(CXX) -o $@ $^
%.o: %.cpp
$(CXX) $(CXXFLAGS) $< -o $@
.PHONY: clean
clean:
rm -f*.o $(TARGET)