用户模式 ​​Linux - 安装模块错误

发布于 2024-08-26 04:55:31 字数 639 浏览 5 评论 0原文

我正在尝试在用户模式 ​​Linux 的模块上运行“make”来安装一个简单的 makefile。这是我的 make 文件:

obj-m    := hello.o

KDIR    := /lib/modules/$(shell uname -r)/build
PWD    := $(shell pwd)

default:
    $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

当我在用户模式 ​​Linux 中运行此文件时,出现以下错误:

make[1]: Entering directory `/lib/modules/2.6.28/build'
make[1]: *** No rule to make target `modules'.  Stop.
make[1]: Leaving directory `/lib/modules/2.6.28/build'
make: *** [default] Error 2

问题是 /lib/modules/ 下不存在任何文件。没有 2.6.28 或 build 的目录。根据我的阅读,这些应该是到 /usr/src 的符号链接,但在 /usr/src 下,我也没有看到任何文件。

I am trying to run 'make' on a module in User Mode Linux to install a simple makefile. Here is my make file:

obj-m    := hello.o

KDIR    := /lib/modules/$(shell uname -r)/build
PWD    := $(shell pwd)

default:
    $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

When I run this in User Mode Linux I get the following error:

make[1]: Entering directory `/lib/modules/2.6.28/build'
make[1]: *** No rule to make target `modules'.  Stop.
make[1]: Leaving directory `/lib/modules/2.6.28/build'
make: *** [default] Error 2

The problem is that no files are present under /lib/modules/. There's no directory for 2.6.28 or build. From what I've read, these should be symlinks to /usr/src, but under /usr/src, I don't see any files under that either.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟花易冷人易散 2024-09-02 04:55:31

必须使用 UML 内核的源代码和标头为其编译模块。

您可以在 UML 内部或仅在主系统中编译它,但您必须使用 UML 的内核标头和构建脚本

Sources and headers of your UML kernel must be used to compile module for it.

You can compile it either inside UML or just in main system, but you must to use UML's kernel's headers and build scripts

小伙你站住 2024-09-02 04:55:31

您需要构建并安装您正在编译的内核版本。从 kernel.org 获取源代码,配置(我认为 make menuconfig 选择配置从正在运行的内核启动),构建并安装它。您可以在普通用户的主目录中进行构建,当然您需要 root 来安装它。

编辑:

以防万一您错过了这一点 - 这里是 用户模式 ​​Linux HOWTO。它包含用于构建和安装内核和模块的特定项目。希望这有帮助。

You need to build and install the version of the kernel you are compiling for. Get the source from kernel.org, configure (I think make menuconfig picks the config up from the running kernel), build, and install it. You can do the build in your home directory under regular user, then of course you would need root to install it.

Edit:

Just in case you missed this - here's User Mode Linux HOWTO. It contains specific items for building and installing kernel and modules. Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文