Makefile Examples
ตัวอย่างไฟล์ Makefile อย่างง่ายแบบที่ 1
all: hello
hello: main.o factorial.o hello.o
g++ main.o factorial.o hello.o -o hello
main.o: main.cpp
g++ -c main.cpp
factorial.o: factorial.cpp
g++ -c factorial.cpp
hello.o: hello.cpp
g++ -c hello.cpp
clean:
rm -rf *o helloตัวอย่างไฟล์ Makefile อย่างง่ายแบบที่ 2
# the compiler to use
CC=g++
# options passed to the compiler
CFLAGS=-c -Wall
all: hello
hello: main.o factorial.o hello.o
$(CC) main.o factorial.o hello.o -o hello
main.o: main.cpp
$(CC) $(CFLAGS) main.cpp
factorial.o: factorial.cpp
$(CC) $(CFLAGS) factorial.cpp
hello.o: hello.cpp
$(CC) $(CFLAGS) hello.cpp
clean:
rm -rf *o helloตัวอย่างไฟล์ Makefile อย่างง่ายแบบที่ 3
ตัวอย่างไฟล์ Makefile อย่างง่ายแบบที่ 4
ตัวอย่างโปรแกรม
Last updated
Was this helpful?