今天例行进行内核编程时,在对自定义的模块进行编译时,出现了如下错误:
make -C /lib/modules/3.2.0-23-generic/build M= modules
make[1]: Entering directory `/usr/src/linux-headers-3.2.0-23-generic'
CHK include/linux/version.h
CHK include/generated/utsrelease.h
make[2]: *** No rule to make target `kernel/bounds.c', needed by `kernel/bounds.s'. Stop.
make[1]: *** [prepare0] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-3.2.0-23-generic'
make: *** [Default] Error 2
各种纠结无果之后,从http://blog.sina.com.cn/s/blog_494725d60100y9x5.html找到了错误原因:
进行编译的时候需要使用sudo -s 获取系统权限,使用sudo时便会引发上述错误。
参考:http://ubuntuforums.org/showthread.php?s=b45cbbed61b642f41afac67c19b1e6f4&t=1047374&page=2
Guys, please read the thread more carefully!
bounds.c is in the file/usr/src/linux-source-2.6.31.tar.bz2 (hint: Thisversion number applies to 9.10) which is only there if you have thepackagelinux-source installed AND extracted (seeabove on how to do this).
Furthermore you've already been given another hint: Try compilingand installing usingsudo -s instead ofsudo. Using sudo -s you'll become superuser akaroot so you have to use this command only once:
$ sudo -s
# a_command_to_be_executed <- executed with full priviledges - please be careful!
# another_command_with_root_rights