关于no rule to make target kernel/bounds.c错误的一种解决办法

本文记录了在自定义模块编译过程中遇到的错误及解决方法。错误出现在尝试编译bounds.c文件时,通过获取系统权限并使用正确的编译命令解决了问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天例行进行内核编程时,在对自定义的模块进行编译时,出现了如下错误:

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 ofsudo. 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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值