zl程序教程

您现在的位置是:首页 >  其他

当前栏目

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

错误模式代码 解决 支持 编译 64 32
2023-09-14 08:57:16 时间
@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