交叉编译Linux SDK —— Makefile

CC = /home/aston/flp/dicpen_rk3326_linux/buildroot/output/rockchip_rk3326_64/host/bin/aarch64-linux-gcc
CXX = /home/aston/flp/dicpen_rk3326_linux/buildroot/output/rockchip_rk3326_64/host/bin/aarch64-linux-g++

TLINCLUDE += -I ./include

target = test

objects =  a.o  b.o  c.o  d.o  e.o  

CFLAGS = $(TLINCLUDE) -fPIC

TLLIBS = -L ./lib

obj = ./


**#测试demo**
all: $(target).o  a.o  b.o  c.o  d.o  e.o 
	$(CXX) $^ $(TLLIBS) -lcurl -lssl -lcrypto -ldl  -lsqlcipher  -o $(target)
all: $(objects)
	$(CC) $^ $(CFLAGS) $(TLLIBS) -lcurl -lssl -lcrypto -ldl -lsqlcipher -lpthread -o $(target)
$(target).o: $(target).c
	$(CC) $(CFLAGS) -c $< -o $(obj)$@
a.o: a.c
	$(CC) $(CFLAGS) -c $< -o $@
b.o: b.c
	$(CC) $(CFLAGS) -c $< -o $(obj)$@
c.o: c.c
	$(CC) $(CFLAGS) -c $< -o $(obj)$@ 	
d.o: d.c
	$(CC) $(CFLAGS) -c $< -o $(obj)$@
e.o: e.cpp
	$(CXX) $(CFLAGS) -c $< -o $@
clean:
	rm -rf *.o
	rm -rf $(obj)*.o
	rm -rf $(objects)
	
	
	

**#so文件**
all: $(objects)
	$(CC) $^ $(CFLAGS) $(TLLIBS) -lcurl -shared -lssl -lcrypto -ldl -lsqlcipher -lpthread -o libxxx.so
a.o: a.c
	$(CC) $(CFLAGS) -c $< -o $@
b.o: b.c
	$(CC) $(CFLAGS) -c $< -o $(obj)$@
c.o: c.c
	$(CC) $(CFLAGS) -c $< -o $(obj)$@ 	
d.o: d.c
	$(CC) $(CFLAGS) -c $< -o $(obj)$@
e.o: e.cpp
	$(CXX) $(CFLAGS) -c $< -o $@
clean:
	rm -rf *.o
	rm -rf $(obj)*.o
	rm -rf $(objects)




**#调用so库**
all: $(target).o
	$(CC) $^ $(CFLAGS) $(TLLIBS) -lcurl -lssl -lcrypto -ldl -lsqlcipher -lpthread -lxxx -o $(target)
$(target).o: $(target).c
	$(CC) $(CFLAGS) -c $< -o $(obj)$@
clean:
	rm -rf *.o
	rm -rf $(obj)*.o
	rm -rf test
上一篇:不同方式编译c程序


下一篇:基于Ubuntu18.04的C语言编程教程(gcc、vim、Makefile)