How to compile the kernel module in Debian

Source: Internet
Author: User
How to compile the kernel module in Debian-Debian, the Linux release technology. For details, refer to the following section. After using Debian, we found that it was difficult to compile the Makefile of the kernel module in Red Hat, because the build directory is unavailable in/lib/modules/'uname-R, no kernel source code. I checked some information online and said that the kernel header file needs to be installed to compile the kernel In Debian.

Apt-get install linux-headers-'uname-R'

Install the currently used kernel header files, build-essential, linux-kbuild, and other packages, if they have not been installed before. Then, a linux-header-xxxxx directory appears under/usr/src, this directory contains the currently used kernel header files and the scripts and Makefile required for the build module. These scripts are provided in linux-kbuild.

Then a linux connection will appear under/usr/src, pointing to linux-headers-xxxxx. You can use this/usr/src/linux connection when writing Makefile. As follows:

Makefile
Obj-m + = xxxx. o
Make-C/usr/src/linux M = $ (PWD) modules

If you do not want to change the Makefile of Red Hat, create a build connection under/lib/modules/'uname-R, then point to/usr/src/linux.

If you do not want to modify/view the kernel source code, you can compile the kernel module. If you want to use the kernel source code, you also need to install the kernel source code.

Apt-get install linux-source-xxxxx

After the installation, a linux-source-xxxx.tar.bz2 package will appear under/usr/src. the kernel source code is displayed in the package.

In Debian 4.0, all the packages mentioned above start with linux, such as linux-source and linux-kbuild. Earlier versions seem to start with kernel, such as kernel-source, kernel-headers and so on

Another thing I don't quite understand is the linux-kernel-headers package. I don't know what it is, I also don't quite understand the difference between the header file in the linux directory under/usr/include and the header file in/usr/src/linux-headers-xxxxx. It must be different anyway.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.