您的位置:首页 > 编程语言

解决编译内核模块helloworld.c:1: 错误:代码模式‘kernel’在 32 位模式下不受支持问题,未编译对64位的支持

2013-11-16 09:44 597 查看

Makefile内容:

KERNELDIR ?=/root/Desktop/work/TI/linux-3.2.0
PWD := $(shell pwd)
obj-m += helloworld.o

default:
    $(MAKE) -C $(KERNELDIR) M=$(PWD) modules

clean:
    @rm -f *.o *.ord* *.sy* *.mod.* *.ko
clean标记中的@表示,执行命令的时候,终端上面不打印rm -r xxx.xx

make出错信息:

[root@localhost ldd3]# make

make -C /root/Desktop/work/TI/linux-3.2.0 M=/root/Desktop/work/ldd3 modules

make[1]: Entering directory `/root/Desktop/work/TI/linux-3.2.0'

CC [M] /root/Desktop/work/ldd3/helloworld.o

/root/Desktop/work/ldd3/helloworld.c:1: 错误:代码模式 ‘kernel’ 在 32 位模式下不受支持

/root/Desktop/work/ldd3/helloworld.c:1: 对不起,尚未实现:未编译入对 64 位模式的支持

make[2]: *** [/root/Desktop/work/ldd3/helloworld.o] 错误 1

make[1]: *** [_module_/root/Desktop/work/ldd3] 错误 2

make[1]: Leaving directory `/root/Desktop/work/TI/linux-3.2.0'

make: *** [default] 错误 2

出错原因:在内核目录中的Makefile,没有指定ARCH、CROSS_COMPILE。因为编译内核的时候,使用的是:make CROSS_COMPILE=arm-linux- ARCH=arm uImage命令,并未修改Makefile文件。

解决:指定ARCH、CROSS_COMPILE内容

ARCH=arm

CROSS_COMPILE=arm-linux-

在编译通过,生成helloworld.ko
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐