且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Linux中编译内核模块时遇到麻烦

更新时间:2023-10-19 12:26:04

请共享您编写的hello-world模块代码.

Pls share the hello-world module code that you have written.

relocs.c位于内核src内的arch/x86/tools下.

relocs.c is present under arch/x86/tools inside the kernel src.

由于您的计算机上仅安装了linux-header,因此可能看不到relocs.c文件. 您必须下载整个内核src.

As you have only linux-headers installed on your machine you may not see relocs.c file. You have to download the entire kernel src.

请按照以下步骤操作:

$ sudo apt-get更新

$ sudo apt-get update

$ sudo apt-get install linux-source.

$ sudo apt-get install linux-source.

作为一个试验(下载内核src之后),您可以更改makefile以将KDIR指向整个内核目录,然后构建您的模块.

As a trial (after downloading kernel src) you can change the makefile to point KDIR to the entire kernel dir and then build your module.