Linux学习记录
2012-01-19 09:06
232 查看
初学Linux,Hello World都弄了很久,此处记录一下。
首先要注意的是,目录名不要带空格,否则需要加上转义符,这导致了此前的make不成功。
shell的出错提示如下:
[enjolras@TMServer Test Test]$ make
make -C /lib/modules/2.6.9-42.ELsmp/build M=/home/enjolras/Test Test modules
make[1]: Entering directory `/usr/src/kernels/2.6.9-42.EL-smp-i686'
make[1]: *** No rule to make target `Test'. Stop.
make[1]: Leaving directory `/usr/src/kernels/2.6.9-42.EL-smp-i686'
make: *** [default] Error 2
[enjolras@TMServer Test Test]$ pwd
/home/enjolras/Test Test
空格没带转义符,导致Makefile中用pwd获取的当前路径不对。
以下为Hello World 的Makefile。
# obj-m is a list of what kernel modules to build. The .o and other
# objects will be automatically built from the corresponding .c file -
# no need to list the source files explicitly.
# 此处指定编译的模块 自动寻找hello_printk.c
# :=代表立刻赋值。用=的话,会有一个展开的过程,一般情况下用:=。
obj-m := hello_printk.o
# KDIR is the location of the kernel source. The current standard is
# to link to the associated source tree from the directory containing
# the compiled modules.
#此处指定内核源码路径 shell 指定当前使用的shell uname -r 指定内核核心版本
KDIR := /lib/modules/$(shell uname -r)/build
# PWD is the current working directory and the location of our module
# source files.
#pwd 获取当前路径
PWD := $(shell pwd)
# default is the default make target. The rule here says to run make
# with a working directory of the directory containing the kernel
# source and compile only the modules in the PWD (local) directory.
# 默认情况下 即输入make不带参数情况下,此make规则将当前工作目录与内核源码一起编译,
#仅仅编译当前目录模块的代码
default:
(TAB)$(MAKE) -C $(KDIR) M=$(PWD) modules
首先要注意的是,目录名不要带空格,否则需要加上转义符,这导致了此前的make不成功。
shell的出错提示如下:
[enjolras@TMServer Test Test]$ make
make -C /lib/modules/2.6.9-42.ELsmp/build M=/home/enjolras/Test Test modules
make[1]: Entering directory `/usr/src/kernels/2.6.9-42.EL-smp-i686'
make[1]: *** No rule to make target `Test'. Stop.
make[1]: Leaving directory `/usr/src/kernels/2.6.9-42.EL-smp-i686'
make: *** [default] Error 2
[enjolras@TMServer Test Test]$ pwd
/home/enjolras/Test Test
空格没带转义符,导致Makefile中用pwd获取的当前路径不对。
以下为Hello World 的Makefile。
# obj-m is a list of what kernel modules to build. The .o and other
# objects will be automatically built from the corresponding .c file -
# no need to list the source files explicitly.
# 此处指定编译的模块 自动寻找hello_printk.c
# :=代表立刻赋值。用=的话,会有一个展开的过程,一般情况下用:=。
obj-m := hello_printk.o
# KDIR is the location of the kernel source. The current standard is
# to link to the associated source tree from the directory containing
# the compiled modules.
#此处指定内核源码路径 shell 指定当前使用的shell uname -r 指定内核核心版本
KDIR := /lib/modules/$(shell uname -r)/build
# PWD is the current working directory and the location of our module
# source files.
#pwd 获取当前路径
PWD := $(shell pwd)
# default is the default make target. The rule here says to run make
# with a working directory of the directory containing the kernel
# source and compile only the modules in the PWD (local) directory.
# 默认情况下 即输入make不带参数情况下,此make规则将当前工作目录与内核源码一起编译,
#仅仅编译当前目录模块的代码
default:
(TAB)$(MAKE) -C $(KDIR) M=$(PWD) modules
相关文章推荐
- Linux学习记录--shell变量
- linux基础学习-第六天记录
- Linux学习记录--命名别名与历史命令
- 记录我的Linux学习之路1
- Linux用户操作(在实验楼的学习记录)
- Linux学习记录--文件系统简介
- linux学习记录:lvm
- linux 命令学习记录
- Linux学习记录--磁盘分区,格式化与检验
- Linux学习记录 - (1)计算机初始化启动过程
- linux基础学习-第四天记录
- 记录自己linux学习的开始
- Linux基础学习记录(一)
- 记录linux学习过程--文本模式下上网
- Linux常用命令学习记录
- Linux 学习记录 三(Vim 文书编辑器).
- Linux-Mysql学习记录
- linux个人学习过程中常用命令及问题记录
- 从头开始学习linux下mysql管理(学习记录)
- 和菜鸟一起学linux之DBUS基础学习记录