Re: [問題] 編譯hello world 模組的問題
※ 引述《suspect1 (嫌犯)》之銘言:
: Dear All:
: 請教有關編譯一個簡單的模組的問題,以下是我的程式碼:
: ********************************************************
: hello.c:
: #include <linux/module.h>
: #if defined(CONFIG_SMP)
: #define __SMP__
: #endif
: #if defined(CONFIG_MODVERSIONS)
: #define MODVERSIONS
: #include <linux/modversions.h>
: #endif
: #include <linux/kernel.h>
: int init_module(void)
: {
: printk(KERN_DEBUG "Hello, kernel!\n");
: return 0;
: }
: void cleanup_module(void)
: {
: printk(KERN_DEBUG "Good-bye, kernel!\n");
: }
module_init(init_module);
module_exit(cleanup_module);
: **************************************************************
: Makefile:
: # standards
: INCLUDE = /usr/src/kernels/2.6.18-1.2798.fc6-i686/hello
: CC = gcc
: CFLAGS = -D__KERNEL__ -I$(INCLUDE) -DMODULE -Wall -O2
: TARGET = hello
: SRC = hello.c
: all: $(TARGET).o
: clean:
: rm -f *.o *~ core
obj-m += hello.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
看你的路徑似乎是使用2.6的kernel,
2.6的kernel使用方式不太一樣囉!
driver跟Makefile的寫法不一樣...
請參考:
http://lwn.net/Articles/driver-porting/
http://tldp.org/LDP/lkmpg/2.6/html/
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.116.226.201
推
06/26 17:23, , 1F
06/26 17:23, 1F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 6 之 6 篇):
LinuxDev 近期熱門文章
PTT數位生活區 即時熱門文章