使用外部工具链编译模块

时间:2012-03-02 08:34:38

标签: linux makefile arm toolchain

我创建了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

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

#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

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

提前致谢,

1 个答案:

答案 0 :(得分:0)

您可以使用remake来调试和了解Makefile。将其作为remake -x -d调用它将为您提供大量调试输出,而其他行为则为GNU make

正如我评论的那样,不要忘记在$(MAKE)内使用make代替Makefile

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

所有这些都无法解决您的问题,但会帮助您理解它

相关问题