如何构建内核模块
我正在尝试编译 此处
我已按照以下步骤操作。
- 下载的Linux内核2.6.35-rc5
- 解压缩到目录/general/source/linux
- 编译了整个内核。
- 在 linux 文件夹中创建了一个 dir test。
- 创建并编译了一个 hello world 模块,如上所述。
当我运行 insmod 命令时,出现此错误
insmod: error inserting 'hello.ko': -1 Invalid module format
如何解决此错误?
问候,
I am trying to compile a hello world module given over here
I have followed the following step.
- Downloaded Linux kernel 2.6.35-rc5
- extracted to directory /general/source/linux
- Complied the entire kernel.
- created a dir test in the linux folder.
- Created and complied a hello world module as mentioned there.
when I run the insmod command, I get this error
insmod: error inserting 'hello.ko': -1 Invalid module format
How do I sort out this error?
Regards,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,你犯的错误是内核版本。
第一次尝试
你会得到内核版本。下载的版本很可能不是您系统的内核版本。
因此,将 make 文件更改为
确保选项卡按照上述脚本中提到的顺序排列。
Ok the mistake that you are making is the kernel version.
First try
You would get the kernel version. The downloaded version mostly likely won't be the kernel version of your system.
So change the make file to
Make sure the tabs are in the order as mentioned in the above script.
您的内核模块必须与正在运行的内核匹配。例如,如果您想安装此特定模块,则还需要安装您构建的内核。
通常,您不会自己构建内核,而是使用与您的发行版内核相匹配的预构建版本。在您的发行版存储库中查找
kernel-headers
包。Your kernel module must match the running kernel. If you want to install this specific module, for example, you'd need to also install the kernel that you've built.
Normally, you'd not build the kernel on your own and use a pre-built version that matches your distribution's kernel. Look for a
kernel-headers
package in your distribution's repository.