Linux 交叉编译 module 范本
hello.c
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("DUal BSD/GPL");
static int hello_init(void)
{
printk(KERN_ALERT "Hello,world\n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye, cruel world\n");
}
module_init(hello_init);
module_exit(hello_exit);
交叉编译Makefile
obj-m := hello.o
KDIR := /home/lah/linux-2.6.31
PWD := $(shell pwd)
CROSS_ARCH := ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-
default:
$(MAKE) $(CROSS_ARCH) -C $(KDIR) M=$(PWD) modules
clean:
rm -rf *.cmd *.o *.mod.c
直接编译,非交叉编译Makefile
obj-m := hello.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KDIR) M=$(PWD) modules
相关推荐
secondid 2020-06-06
benico 2020-06-04
ZGCdemo 2020-05-13
wenjs00 2020-05-05
RayCongLiang 2020-02-03
狼窝 2020-02-02
Dlanguage 2020-01-03
lightindark 2013-06-12
jiangtie 2019-12-20
pointfish 2019-12-14
WenFY的CSDN 2019-12-13
adc00 2019-12-08
lyaqys 2010-08-07
宅学部落王利涛 2010-07-17
夜明二 2011-03-22
xinyao0 2011-02-20
amethystqi 2010-12-16