linux - 设备驱动程序代码编译?

标签 linux linux-kernel linux-device-driver kernel-module

我是 linux 的新手。我必须编译一个设备驱动程序示例代码。

我尝试从 synaptic 安装 linux-source-2.6.38,然后它显示了下面引用的消息:

This package provides the source code for the Linux kernel version 2.6.38.

This package is mainly meant for other packages to use, in order to build custom flavours.

If you wish to use this package to create a custom Linux kernel, then it is suggested that you investigate the package kernel-package, which has been designed to ease the task of creating kernel image packages.

If you are simply trying to build third-party modules for your kernel, you do not want this package. Install the appropriate linux-headers package instead.

所以感到困惑:

1) 我的设备驱动程序代码编译是否需要 linux 源代码?

2) 如果我安装了新内核,我该如何使用新内核?

最佳答案

您可能需要像 linux-headers-2.6-amd64linux-kbuild-2.6 这样的软件包。使用 apt-cache search linux headersapt-cache search linux kbuild 来准确找到包的名称。

您可以使用 apt-cache search linux headersapt-cache search linux kbuild 来获取包的确切名称。

如果您正在制作一个模块(一个可动态加载的内核模块*.ko),您不需要构建一个新内核。使用 insmodmodprobe 加载它。

关于linux - 设备驱动程序代码编译?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9208833/

相关文章:

c - 如何通过 sched_setaffinity 在多个 CPU 上设置亲和性

linux - 如何在文件中搜索多行并在 bash/dash 中注释这些行

linux - 读/写阻塞的系统调用是否会将进程置于 TASK_UNINTERRUPTIBLE 或 TASK_INTERRUPTIBLE 状态?

audio - Linux Mint 17完全没有声音

linux - 字符设备的动态注册为我的字符设备分配了与 Documentation/devices.txt 不对应的主编号。这是为什么?

linux - 使用 sed 在文件中特定行的末尾添加包含斜杠的文本

linux - Unix 上的 "^+CHAR"命令(例如 ^C 停止当前命令)有什么作用?

linux - 为什么我在使用 linux hrtimer 进行一秒回调时会出现时间漂移?

c - 如何从内核空间确定 PID 位于哪些 namespace 中?

linux - dts和ACPI的区别