[英]< insmod: ERROR: could not insert module GSM.ko: Unknown symbol in module. > How to fix it?
I have written a simple loadable kernel module.我编写了一个简单的可加载 kernel 模块。 To create a character device file in /dev/ and a related class directory.在 /dev/ 和相关的 class 目录中创建字符设备文件。 The following lines I have added in the project.我在项目中添加了以下几行。
MODULE_DESCRIPTION("GSM driver");
MODULE_LICENSE("Dual BSD/GPL");
MODULE_AUTHOR("Guruprasad");
MODULE_DESCRIPTION("A simple driver");
MODULE_VERSION("0.1");
While building I got the following warning在构建时,我收到以下警告
WARNING: modpost: missing MODULE_LICENSE() in /home/.../char_dev_gsm/GSM.o
While inserting I got the following error:插入时出现以下错误:
insmod: ERROR: could not insert module GSM.ko: Unknown symbol in module
Please help me with this.请帮我解决一下这个。
The project has one main file (GSM.c) and an include file (device.c and device.h)该项目有一个主文件 (GSM.c) 和一个包含文件 (device.c 和 device.h)
Please get the files from the following link.请从以下链接获取文件。 https://github.com/guruprasad-92/Device-Driver https://github.com/guruprasad-92/Device-Driver
I've tried with adding the line MODULE_LICENSE("Dual BSD/GPL");
我尝试添加MODULE_LICENSE("Dual BSD/GPL");
in file device.c which results no warning messages and no error messages as well, but while inserting the module it neither creates the device file /dev/gsm0
nor updating the $dmesg
with printk()
related messages.在文件 device.c 中,这不会导致警告消息和错误消息,但是在插入模块时,它既不会创建设备文件/dev/gsm0
,也不会使用printk()
相关消息更新$dmesg
。
I have also tried with writing the functions register_dev()
and unregister_dev()
in the file GSM.c which did not results any warning, and created the the device /dev/gsm0
and class directory in /sys/class/我还尝试在文件 GSM.c 中编写函数register_dev()
和unregister_dev()
,但没有产生任何警告,并在 /sys/class/ 中创建了设备/dev/gsm0
和 class 目录
But I want to know why the file inclusion is giving warning while building.但我想知道为什么文件包含在构建时会发出警告。
The main problem is that the module is GSM.ko is built from multiple.c files (GSM.c and device.c), and the basename of the module is the same as the basename of one of the.c files (which is only allowed when the module is built from a single.c file). The main problem is that the module is GSM.ko is built from multiple.c files (GSM.c and device.c), and the basename of the module is the same as the basename of one of the.c files (which is仅当模块从单个.c 文件构建时才允许)。
To fix it, you can rename GSM.c to (for example) gsm.c and change the GSM-objs
line in the Makefile:要修复它,您可以将 GSM.c 重命名为(例如)gsm.c 并更改 ZB67911656EF5D18C4AE36CB6741B7 中的GSM-objs
objs 行
obj-m := GSM.o
GSM-objs = gsm.o device.o
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.