【问题标题】:What is wrong With make?make有什么问题?
【发布时间】:2011-10-08 23:59:21
【问题描述】:

C

#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void)
{
    printk(KERN_INFO "Hello world 1.\n");
    return 0;
}
void cleanup_module(void)
{
    printk(KERN_INFO "Goodbye world 1.\n");
}

/* makefile */
/* uname -r = 2.6.32-5-686 */
obj-m += hello.o
all :
    make -C /lib/modules/2.6.32-5-686/build /home/mgh/Documents modules
clean : 
    make -C /lib/modules/2.6.32-5-686/build /home/mgh/Documents clean

root@localhost:/home/mgh/Documents# make
make -C /lib/modules/2.6.32-5-686/build /home/mgh/Documents modules
make[1]: Entering directory /usr/src/linux-headers-2.6.32-5-686'
/usr/src/linux-headers-2.6.32-5-common/scripts/Makefile.build:44: /usr/src/linux-headers-``2.6.32-5-common/scripts/basic/Makefile: No such file or directory
make[5]: *** No rule to make target `/usr/src/linux-headers-2.6.32-5-common/scripts/basic``/Makefile'.  Stop.
make[4]: *** [scripts_basic] Error 2
make[3]: Nothing to be done for `/home/mgh/Documents'.
make[3]: *** No rule to make target `include/config/auto.conf', needed by `include/config``/kernel.release'.  Stop.
make[2]: *** [sub-make] Error 2
make[1]: *** [all] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-5-686'
make: *** [all] Error 2

【问题讨论】:

  • 引用 Scott Meyers 的话:“make?谁需要臭臭的make?”。

标签: c linux module header makefile


【解决方案1】:

猜测:您没有在自定义 Makefile 中设置 M 环境变量。见http://tldp.org/LDP/lkmpg/2.6/html/x181.html

下次,请确实提出比“出了什么问题?”更具体的问题

【讨论】:

  • 我这样做就像make -C /lib/modules/2.6.32-5-686/build M=/home/mgh/Documents modules 但错误仍然存​​在! :( 我的操作系统是 debian 挤压,我想我没有一些文件,如头文件或......(我是 linux 的新手)
  • 不,您在评论中写的不是您在问题中写的。如果您是新手,请查看内核模块教程之一,并按照字面意思进行操作。然后,如果您遇到问题,请提出更具体的问题。
【解决方案2】:

我怀疑make 有什么问题。不过,我非常确定您的 Makefile 有问题。根据一些随机的互联网搜索,尝试这样的事情:

make -C /lib/modules/2.6.32-5-686/build SUBDIRS=/home/mgh/Documents modules

这是假设您的 Makefile 位于 /home/mgh/Documents

【讨论】:

  • 你有没有按照我的建议换行?
猜你喜欢
  • 2019-11-08
  • 2011-10-25
  • 1970-01-01
  • 2019-01-21
  • 1970-01-01
  • 2023-03-18
  • 1970-01-01
  • 2010-10-20
  • 2010-11-14
相关资源
最近更新 更多