当前位置: 首页 > >

Makefile样例

发布时间:

Makefile1



src = $(wildcard ./*cpp)
obj = $(patsubst %.cpp, %.o,$(src))

target = test

$(target) : $(obj)
g++ $(obj) -o $(target) -I/usr/include/mysql -L/usr/lib/mysql/ -lmysqlclient

%.o: %.cpp
g++ -c $< -o $@ -I/usr/include/mysql -L/usr/lib/mysql/ -lmysqlclient

.PHONY:clean
clean:
rm -f $(target) $(obj)

Makefile2



CFLAGS = -g
target = test
INCLUDE = -I /usr/include/mysql
lib = -lmysqlclient
dirlib = -L /usr/lib/mysql/

src = $(wildcard *.cpp)
objs = $(patsubst %.cpp,%.o,$(src))

$(target) : $(objs)
g++ $(CFLAGS) $(objs) $(dirlib) $(lib) -o $(target) $(INCLUDE)

%.o: %.cpp
g++ $(CFLAGS) $(INCLUDE) $(lib) $(dirlib) -c $< -o $@

.PHONY:clean
clean:
rm -f $(target) $(objs)

?



转载于:https://www.cnblogs.com/wanghao-boke/p/11068427.html






相关资源:makefile



友情链接: