linux makefile 编译c和c++文件

.SUFFIXES:.c .o //.c和.o建立关联CC=gccSRCS=hello.c\add.c //同时编译两个.c文件OBJS=$(SRCS:.c=.o)//ORJS=hello.o add.oEXEC=hellostart: $(OBJS) //依赖hello.o add.o$(CC) -o $(EXEC) $(OBJS)@echo ‘—————-ok————‘.c.o:$(CC) -o $@ -c $< //自动根据$(OBJS) 中.o的数量循环编译, 直到编译完所有的.c文件clean:rm -f $(OBJS)**hello.c内容**#include <stdio.h>#include “add.h”int main(int arg, char *args[]){printf(“add = %d\n”, add(12, 56));return 0;}**add.h内容**#ifndef PUB_H_#define PUB_H_int add(int a, int b);#endif add(int a, int b){return a + b;}

,再长的路,一步步也能走完,再短的路,不迈开双脚也无法到达。

linux makefile 编译c和c++文件

相关文章:

你感兴趣的文章:

标签云: