好记性不如烂笔头系列:编译ko模块相关
2015-04-07 10:50
316 查看
环境:
hello.c
Makefile:
[root@ko]# pwd /home/android/android-4.0/ko [root@ko]# ls hello.c Makefile
[root@omap]# pwd /home/android/android-4.0/omap [root@omap]# ls arch drivers Kbuild mm scripts block firmware Kconfig Module.symvers security COPYING fs kernel net sound CREDITS include lib README tools crypto init MAINTAINERS REPORTING-BUGS usr Documentation ipc Makefile samples virt
hello.c
#include <linux/init.h> #include <linux/module.h> #include <linux/kernel.h> static int __init hello_init(void) { printk("hello world!\n"); char cs[2] = {"xy""a"}; printk("cs[1] = %c\n",cs[1]); int a = 2; printk("a=%d\n",a); return 0; } static void __exit hello_exit(void) { printk("Goodbye\n"); } module_init(hello_init); module_exit(hello_exit); MODULE_LICENSE("GPL");
Makefile:
CROSS_COMPILE := /home/android/android-4.0/arm-2010q1/bin/arm-none-eabi- ARCH := arm CC := $(CROSS_COMPILE)gcc LD := $(CROSS_COMPILE)ld obj-m := hello.o KDIR := /home/android/android-4.0/omap PWD := $(shell pwd) modules: export ARCH=arm #这句不应该写这里,在命令行运行先,不然make时会导致错误。cc1: error: unrecognized command line option "-m64" $(MAKE) -C $(KDIR) M=$(PWD) modules clean: rm *.o -rf rm *.mod.* -rf rm *odule* -rf
相关文章推荐
- 好记性不如烂笔头-手动编译jar包<转>
- 好记性不如烂笔头43-javaWeb中Session相关事件监听器(7)
- 好记性不如个破笔头之--GAC
- 好记性不如烂笔头
- 编译内核模块 .ko文件的注意事项 缺少:mmzone.h bounds.h
- 好记性不如烂笔头
- 好记性不如烂笔头
- DNN模块开发系列文章(4)——与模块开发相关的类
- Oracle函数小全||记录下来,用处多多啊——好记性不如烂笔头
- 模块编译KO文件Makefile 2.6内核通用
- 7z系列之一:7zip SDK中C++模块的编译
- 浅析linux内核编译及相关模块加载
- 原创:在VS2005嵌入式环境下安装wxWidgets——好记性不如烂笔头
- 记性不如烂笔头
- 好记性不如烂笔头!!
- 好记性不如烂笔头(1)
- 好记性不如烂笔头
- 好记性不如烂笔头 安装IIS及其发布asp.net网站
- 烂记性不如好笔头㈠㈢㈥
- 编译内核模块 .ko文件的注意事项 缺少:mmzone.h bounds.h