今天例行進行內核編程時,在對自定義的模塊進行編譯時,出現了如下錯誤:
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 thepackage
linux-source installed
AND extracted (seeabove on how to do this).
Furthermore you've already been given another hint: Try compilingand installing using
sudo -s instead of
sudo. Using sudo -s you'll become superuser akaroot so you have to use this command only once:
Code:
$ sudo -s
# a_command_to_be_executed <- executed with full priviledges - please be careful!
# another_command_with_root_rights