閱讀427 返回首頁    go 阿裏雲 go 技術社區[雲棲]


解決編譯內核模塊helloworld.c:1: 錯誤:代碼模式‘kernel’在 32 位模式下不受支持問題,未編譯對64位的支持

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


最後更新:2017-04-03 14:54:20

  上一篇:go directdraw顯示yuv422(yuy2)
  下一篇:go dell 服務器係統安裝及RAID配置