无法编译内核模块:没有 .ko 文件输出
我已经构建了一个 android 内核(源代码),现在我我正在尝试为其交叉编译内核模块,准确地说是v4l2loopback
。我使用这个工具链来构建内核(内核版本为4.9)。
在github上你可以看到有人确实成功编译了该模块,我一直在尝试自己复制他们的成功。但在实际构建内核模块的最后阶段,我没有得到 .ko
文件输出。这是我得到的:
# setting up
$ export ARCH=arm64
$ export CROSS_COMPILE=aarch64-linux-android-
$ export PATH=/home/username/redmi_7a/aarch64-linux-android-4.9-kernel/bin:$PATH
# go to the source code directory
$ cd v4l2loopback
$ export M="$PWD"
# I have the compiled kernel at /home/username/redmi_7a/kernel
make -C ../kernel
make: entering catalogue «/home/username/redmi_7a/kernel»
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
CHK include/generated/bounds.h
CHK include/generated/timeconst.h
CHK include/generated/asm-offsets.h
CALL scripts/checksyscalls.sh
CHK scripts/mod/devicetable-offsets.h
Building modules, stage 2.
MODPOST 4 modules
make: exiting catalogue «/home/username/redmi_7a/kernel»
看起来没有错误,什么也没有,但我得到的只是一个 v4l2loopback.o
文件,而不是 v4l2loopback.ko
文件,如 < a href="https://github.com/umlaeute/v4l2loopback#build" rel="nofollow noreferrer">v4l2loopback github 页面。
我尝试 find 。 -name "*.ko"
,但它没有返回任何内容。
我可能在内核编译过程中搞砸了一些东西,所以它可能不是模块的错。我真的不知道该去哪里看,我对此很陌生。
也许我需要在内核 .config
文件中设置一些标志并重新编译?
我真正问的只是一个方向,我可能做错了什么?
I've built an android kernel (source code), now I'm trying to cross-compile a kernel module for it, v4l2loopback
to be precise. I've used this toolchain to build the kernel (kernel version is 4.9).
Here on github you can see that someone actually succeeded in compiling the module, and I've been trying to replicate their success myself. But in the last stage of actually building the kernel module I don't get a .ko
file output. Here is what I get:
# setting up
$ export ARCH=arm64
$ export CROSS_COMPILE=aarch64-linux-android-
$ export PATH=/home/username/redmi_7a/aarch64-linux-android-4.9-kernel/bin:$PATH
# go to the source code directory
$ cd v4l2loopback
$ export M="$PWD"
# I have the compiled kernel at /home/username/redmi_7a/kernel
make -C ../kernel
make: entering catalogue «/home/username/redmi_7a/kernel»
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
CHK include/generated/bounds.h
CHK include/generated/timeconst.h
CHK include/generated/asm-offsets.h
CALL scripts/checksyscalls.sh
CHK scripts/mod/devicetable-offsets.h
Building modules, stage 2.
MODPOST 4 modules
make: exiting catalogue «/home/username/redmi_7a/kernel»
Seems like no errors, no nothing, but all I get is a v4l2loopback.o
file, instead of v4l2loopback.ko
file, as mentioned per v4l2loopback github page.
I tried find . -name "*.ko"
, but it didn't return anything.
I might've screwed something up during the kernel compilation, so it might not module's fault. I don't really know where to look, I'm really new to this.
Maybe I need to set some flag in the kernel .config
file and recompile?
All I really ask is a direction, what are the things I might've done wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您似乎构建不正确。使用
make -C ../kernel
您完全忽略了您尝试构建并使用内核Makefile< 的模块存储库中的
Makefile
/code> 单独。您应该查看v4l2loopback
内的Makefile
并注意文件开头的以下几行:因此
PWD
和内核目录是已经为你设置好了。您应该只覆盖KERNEL_DIR
和所需的交叉编译变量:上面的代码在我的机器上运行并正确生成
v4l2loopback.ko
。当然,在执行此操作之前请确保您已经构建了内核。You seem to be building incorrectly. With
make -C ../kernel
you are completely ignoring theMakefile
that is in the repository of the module you are trying to build and using the kernelMakefile
alone. You should take a look at theMakefile
insidev4l2loopback
and notice the following lines at the beginning of the file:So the
PWD
and kernel dir are already set for you. You should just overrideKERNEL_DIR
and the needed cross-compilation variables:The above works on my machine and correctly produces
v4l2loopback.ko
. Make sure you have built the kernel before doing this of course.