
- Makefile 教程
- Makefile - 主頁
- Makefile - 為什麼使用 Makefile?
- Makefile - 宏
- Makefile - 依賴項
- Makefile - 規則
- Makefile - 字尾規則
- Makefile - 指令
- Makefile - 重新編譯
- Makefile - 其他功能
- Makefile - 示例
- Makefile 快速指南
- Makefile - 快速指南
- Makefile - 有用資源
- Makefile - 討論
Makefile - 示例
這是用於編譯 hello 程式的 Makefile 示例。此程式由三個檔案組成:main.cpp、factorial.cpp 和 hello.cpp。
# Define required macros here SHELL = /bin/sh OBJS = main.o factorial.o hello.o CFLAG = -Wall -g CC = gcc INCLUDE = LIBS = -lm hello:${OBJ} ${CC} ${CFLAGS} ${INCLUDES} -o $@ ${OBJS} ${LIBS} clean: -rm -f *.o core *.core .cpp.o: ${CC} ${CFLAGS} ${INCLUDES} -c $<
現在,您可以使用 make 構建您的程式 hello。如果您發出命令 make clean,則它將刪除當前目錄中可用的所有目標檔案和核心檔案。
廣告