Chinaunix
标题:
ubuntu 编译 hello模块有错误
[打印本页]
作者:
weiwotianyuan
时间:
2010-07-08 22:05
标题:
ubuntu 编译 hello模块有错误
我用ubuntu10.04编译hello模块出现错误,程序如下
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void) //有的上面定义的是init_modules(void)是通不过编译的
{
printk(KERN_ALERT "Hello, world\n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye, world\n");
}
module_init(hello_init);
module_exit(hello_exit);
Makefile文件如下:
PWD = $(shell pwd)
KERNEL_SRC = /usr/src/linux-headers-2.6.32-22-generic/
obj-m := hello.o
module-objs := hello.o
all:
$(MAKE) -C $(KERNEL_SRC) M=$(PWD) modules
clean:
rm *.ko
rm *.o
出现以下错误提示:
make -C /usr/src/linux-headers-2.6.32-22-generic/ M=/root/text/hello2 modules
make[1]: 正在进入目录 `/usr/src/linux-headers-2.6.32-22-generic'
CC [M] /root/text/hello2/hello.o
cc1: error: unrecognized command line option "-mlittle-endian"
cc1: error: unrecognized command line option "-mapcs"
cc1: error: unrecognized command line option "-mno-sched-prolog"
cc1: error: unrecognized command line option "-mabi=apcs-gnu"
make[2]: *** [/root/text/hello2/hello.o] 错误 1
make[1]: *** [_module_/root/text/hello2] 错误 2
make[1]:正在离开目录 `/usr/src/linux-headers-2.6.32-22-generic'
make: *** [all] 错误 2
由于是第一次弄这个,所以没有经验,只好问问论坛里的高手了
作者:
openspace
时间:
2010-07-09 11:11
你的kernel是发行版自带的还是自己编译的
要不安装个kernel-devel包试试
作者:
zyr-linux
时间:
2010-07-10 17:52
ubuntu默认安装缺了很多东东,试试:
apt-get install build-essential
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2