用于ARM设备的交叉编译Hello.c模块

时间:2013-09-27 20:20:29

标签: android c++ c linux gcc

我正在尝试交叉编译一个简单的Hello world程序,我计划将其作为模块上传到android ARM设备中。下面是c代码。

#include<linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>

MODULE_LICENSE("GPL");
MODULE_AUTHOR("CW");
MODULE_DESCRIPTION("Demo Hello");

static int init_module(void)
{
      printk(KERN_ALERT "Hello World\n");

      return 0;
}

static void cleanup_module(void)
{
      printk(KERN_ALERT "Good Bye World\n");
}

module_init(init_module);
module_exit(cleanup_module);

以下是 makefile

VERSION = 3
PATCHLEVEL = 2
SUBLEVEL = 0
EXTRAVERSION = 00763-g4071679


obj-m :=hello.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)

default:
    $(MAKE) ARCH=arm CROSS_COMPILE=/home/userid/rowboat-android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi- -C $(KDIR) SUBDIRS=$(PWD) modules

clean:
    $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean

以下是错误日志的初始部分

make ARCH=arm CROSS_COMPILE=/home/userid/rowboat-android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi- -C /lib/modules/3.5.0-23-generic/build SUBDIRS=/home/userid/myfiles modules
make[1]: Entering directory `/usr/src/linux-headers-3.5.0-23-generic'
    CC [M]  /home/userid/myfiles/hello.o
    In file included from /usr/src/linux-headers-3.5.0-23-generic/arch/arm/include/asm/types.h:4,
             from include/linux/types.h:4,
             from include/linux/init.h:5,
             from /home/userid/myfiles/hello.c:1:
 include/asm-generic/int-ll64.h:11:29: error: asm/bitsperlong.h: No such file or directory
  In file included from /usr/src/linux-headers-3.5.0-23-generic/arch/arm/include/asm/posix_types.h:35,
             from include/linux/posix_types.h:35,
             from include/linux/types.h:17,
             from include/linux/init.h:5,
             from /home/userid/myfiles/hello.c:1:

主机上 uname -r =&gt; 3.5.0-23 generic =&gt; Ubuntu 12.04 LTS

Android ARM设备 / proc / version =&gt; Linux版本3.2.0-00763-g407167a(gcc版本4.4.3(GCC))....

提前感谢您的帮助。

0 个答案:

没有答案