我尝试编译简单的内核模块。但接受以下消息
make -C /lib/modules/3.18.3/build SUBDIRS=/home/sekwon/study/tree/b+tree modules
make[1]: Entering directory `/home/sekwon/study/linux-3.18.3'
Building modules, stage 2.
MODPOST 1 modules
WARNING: "btree_insert" [/home/sekwon/study/tree/b+tree/lsk_b+tree.ko] undefined!
WARNING: "btree_geo32" [/home/sekwon/study/tree/b+tree/lsk_b+tree.ko] undefined!
WARNING: "btree_init" [/home/sekwon/study/tree/b+tree/lsk_b+tree.ko] undefined!
WARNING: "btree_destroy" [/home/sekwon/study/tree/b+tree/lsk_b+tree.ko] undefined!
make[1]: Leaving directory `/home/sekwon/study/linux-3.18.3'
以下是我的模块源代码
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/btree.h>
struct btree_head bptree_head;
static int bptree_init(void)
{
int i, val[10];
unsigned long key[10];
int result;
printk(KERN_ALERT"B+tree start!\n");
for(i = 0; i < 10; i++)
{
key[i] = 1*(i+1);
val[i] = 10*(i+1);
}
result = btree_init(&bptree_head);
for(i = 0; i < 10; i++)
{
result = btree_insert(&bptree_head, &btree_geo32, &key[i], &val[i], 0);
printk(KERN_ALERT"Insert key(%ld) val(%d)\n",key[i],val[i]);
}
printk(KERN_ALERT"Insert finish\n");
return 0;
}
static void bptree_exit(void)
{
printk(KERN_ALERT "B+tree finish\n");
btree_destroy(&bptree_head);
}
module_init(bptree_init);
module_exit(bptree_exit);
MODULE_LICENSE("Dual BSD/GPL");
以下是我的Makefile
obj-m :=lsk_b+tree.o
KDIR :=/lib/modules/$(shell uname -r)/build
PWD :=$(shell pwd)
default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
rm -rf *.ko
rm -rf *.mod.*
rm -rf .*.cmd
rm -rf *.o
哪个问题??
请帮助我〜!!答案 0 :(得分:1)
我解决了这个问题!!
我发现编译的内核模块不包含B Tree模块(btree)
所以,我尝试更改配置以编译B树模块