国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Linux > 正文

Linux驅動Invalid module format錯誤解決

2024-06-28 13:03:26
字體:
來源:轉載
供稿:網友
 

1.編譯錯誤(其實這個問題和 Makefile有很大關系)

2.Invalid module format 錯誤

3.insmod: error inserting './hello.ko': -1 File exists

開發環境

內核版本:2.6.22(我下載的最新版本)

gcc:gcc (GCC) 4.1.2

Makefile

gcc -D__KERNEL__ -DMODULE -Dlinux -I /usr/local/src/linux2.4/include -c -o hello.o hello.c

上面這種寫法適合 2.4 版本的內核,在2.6下用這種寫法很可能導致許多編譯錯誤,即使編譯通過也會產生 Invalid module format 錯誤。

2.6下正確的 Makefie 如下:

# Makefile2.6ifneq ($(KERNELRELEASE),)#kbuild syntax. dependency relationshsip of files and target modules are listed here.mymodule-objs := hello.oobj-m := hello.o elsePWD := $(shell pwd)KVER ?= $(shell uname -r)KDIR := /lib/modules/$(KVER)/buildall:$(MAKE) -C $(KDIR) M=$(PWD)clean:rm -rf .*.cmd *.o *.mod.c *.ko .tmp_versionsendif

使用上面的 Makefie 同時也解決了 Invalid module format 錯誤

insmod: error inserting './hello.ko': -1 File exists 錯誤解決

第一次insmod ./hello.ko 沒有輸出表示你的模塊被正常載入了,后來的錯誤是你重復載入這個模塊導致的

用命令 lsmod | grep hello 看看是不是有這個模塊?

用命令 tail /var/log/messages

有 hello,world

module程序正常執行。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 林西县| 南昌县| 曲靖市| 进贤县| 双辽市| 怀远县| 习水县| 平谷区| 芦溪县| 巩义市| 聂荣县| 安龙县| 柳州市| 枣强县| 丹阳市| 肥城市| 东平县| 房产| 军事| 县级市| 宁阳县| 凤冈县| 乐都县| 蓬安县| 顺平县| 荆州市| 玛沁县| 府谷县| 淅川县| 大同市| 屏东市| 大洼县| 巫溪县| 芜湖县| 黔东| 都兰县| 华安县| 赫章县| 娄烦县| 乌审旗| 黔南|