我创建了make文件

    obj-m += hello.o

all:
    make -C /home/developer/Desktop/xukr-20120201-omap3/linux-2.6.37-tn M=/home/developer/Desktop/module_test  modules

clean:
    make -C /home/developer/Desktop/xukr-20120201-omap3/linux-2.6.37-tn M=/home/developer/Desktop/module_test clean


然后,我找到了一个简单的hello程序

#define __KERNEL__         /* We're part of the kernel */
#define MODULE             /* Not a permanent part, though. */

/* Standard headers for LKMs */
#include <linux/modversions.h>
#include <linux/module.h>

#include <linux/tty.h>      /* console_print() interface */

/* Initialize the LKM */
int init_module()
{
  console_print("Hello, world - this is the kernel speaking\n");
  /* More normal is printk(), but there's less that can go wrong with
     console_print(), so let's start simple.
  */

  /* If we return a non zero value, it means that
   * init_module failed and the LKM can't be loaded
   */
  return 0;
}


/* Cleanup - undo whatever init_module did */
void cleanup_module()
{
  console_print("Short is the life of an LKM\n");
}


我试图以此在命令行上进行编译

make ARCH=arm CROSS_COMPILE=angstrom-linux-gnueabi-


我得到这个错误

/bin/sh: angstrom-linux-gnueabi-gcc: not found


这有什么问题?我真的很新。

提前致谢,

最佳答案

您可以使用remake调试和了解您的Makefile。以remake -x -d的形式调用它会给您很多调试输出,而以GNU make的形式出现。

正如我所评论的,不要忘记在$(MAKE)中使用make而不是Makefile

关于错误:angstrom-linux-gnueabi-gcc: not found,您需要在系统上安装适当的交叉编译器(和交叉链接器)工具链(或者可能适当地设置了PATH环境变量,以便可以找到它)。

所有这些都不能解决您的问题,但可以帮助您理解它

关于linux - 带有外部工具链的编译模块,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9530225/

10-13 09:37
查看更多