编译使用动态库, 编译ko makefile

动态库makefile 举例

CURR_DIR := $(shell pwd)

MAKE = make
ASAN_CFLAGS += -fsanitize=address -fsanitize-recover=address 
ASAN_OPTIONS=halt_on_error=0
ASAN_LDFLAGS += -fsanitize=address -g1
CLEAN = make clean
CC = /opt/toolchains/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
LDFLAGS += -I./
export CC
RM = rm -rf
TARGET_NAME = nca9555.so

$(TARGET_NAME): nca9555.c
	$(CC) -shared -fPIC nca9555.c -o $(TARGET_NAME) $(LDFLAGS) 
	cp nca9555.so ../
	@echo $(shell pwd)
	
clean:
	rm nca9555.so
.PHONY:clean

使用动态库举例

CURR_DIR := $(shell pwd)

MAKE = make
ASAN_CFLAGS += -fsanitize=address -fsanitize-recover=address 
ASAN_OPTIONS=halt_on_error=0
ASAN_LDFLAGS += -fsanitize=address -g1
CLEAN = make clean
CC = /opt/toolchains/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
LDFLAGS += -I./
export CC
RM = rm -rf
TARGET_NAME = io_test

$(TARGET_NAME):main.c 
	$(CC) main.c -o $(TARGET_NAME) nca9555.so
	@echo $(shell pwd)
	
clean:
	rm io_test
.PHONY:clean

编译ko

COMPILE=/media/xyding_60035/quanzhi/new_T3/lichee/out/sun8iw11p1/linux/common/buildroot/host/usr/bin/arm-linux-gnueabihf-
CC:=$(CROSS_COMPILE)gcc
LD:=$(CROSS_COMPILE)ld

obj-m:=gnss.o  

KERNEL_PATH := /media/xyding_60035/quanzhi/new_T3/lichee/linux-3.10

PWD:=$(shell pwd)

all:
	make ARCH=arm CROSS_COMPILE=$(COMPILE) -C $(KERNEL_PATH) M=$(PWD) modules

clean:
	make -C $(KERNEL_PATH) SUBDIRS=$(PWD) clean

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值