A tragic experience compiling the first kernel module

Source: Internet
Author: User

Today, I compiled my first kernel module but there was an error, and the result is as follows:

650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M00/7D/F9/wKiom1bz5Z2Dg-lxAAG02OIwqSM821.jpg "style=" float: none; "title=" qq20160324205446.jpg "alt=" Wkiom1bz5z2dg-lxaag02oiwqsm821.jpg "/>

And my makefile and C files are like this:

650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M02/7D/F9/wKiom1bz5Z6TjxS-AADbKR4aV68387.jpg "style=" float: none; "title=" qq20160324205617.jpg "alt=" Wkiom1bz5z6tjxs-aadbkr4av68387.jpg "/>

650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M02/7D/F6/wKioL1bz5jih7HfXAAFnXsKO8Ac934.jpg "style=" float: none; "title=" qq20160324205643.jpg "alt=" Wkiol1bz5jih7hfxaafnxsko8ac934.jpg "/>

At the beginning, I thought it was makefile wrong, especially "obj-m: =", this I changed several times, on-line all kinds of writing have been used, such as:

Obj-m: =MEMDEV.O #要生成的模块名

Memdevmodule-objs:=module #生成这个模块名所需要的目标文件

After using the compilation results or errors, find someone else to write the confirmed correct makefile and C files, the same cannot be compiled successfully! In the end there is no way, I have to recompile the kernel, regenerate Vmlinuz, and Initramfs file, this is the newly generated file: 650) this.width=650; "Src=" http://s2.51cto.com/wyfs02/M00/ 7d/f6/wkiol1bz6ekgpfrdaabrz6mrpzy321.png "title=" qq picture 20160324210932.png "alt=" wkiol1bz6ekgpfrdaabrz6mrpzy321.png "/>

It took nearly two hours, after compiling these two files, even the kernel has changed, it is always OK, but the fact is, but cannot generate. ko files. The mood is extremely sad. Suddenly think of a v=1, see the detailed compilation process:

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/7D/F6/wKioL1bz6fvwa7oUAAMpeYvVm4M748.jpg "title=" Qq20160324211653.jpg "alt=" Wkiol1bz6fvwa7ouaampeyvvm4m748.jpg "/>

Well, finally found the reason, but into the kernel ls a bit, the file can be found:

650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M02/7D/F6/wKioL1bz60WRA1-iAABTNNfdMaI314.jpg "style=" float: none; "title=" 1.jpg "alt=" Wkiol1bz60wra1-iaabtnnfdmai314.jpg "/>

650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M00/7D/FA/wKiom1bz6qyx0uZaAABEPXci4xo822.jpg "style=" float: none; "title=" qq20160324212228.jpg "alt=" Wkiom1bz6qyx0uzaaabepxci4xo822.jpg "/>

Just started to think that just their own virtual machine configuration problems, in others that find a copy of Vmlinuz and Initramfs files, restart the virtual machine, the tragedy is still a problem. Well, really can not find the problem, ready to delete this virtual machine, pure new installation of one.

Did not think of the first compile kernel module is this tragic experience, at the same time I also have a problem, since I wrote a simple module can not compile, but the official website download kernel code and why can compile the bzimage and modules files?

Drive learning road or long ah, re-install a virtual machine, and then to compile it!

This article is from the "Wind and Drift" blog, please be sure to keep this source http://yinsuifeng.blog.51cto.com/10173491/1754980

A tragic experience compiling the first kernel module

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.