my first Linux kernel code with some problems in Makefile maybe...
sorry for writing this in English, Because there are no Sougou in my Linux....-----------------------------------------------------------------------------
Ok, this is my first try to write some kernel code, and definitely, I have meat some trouble.
There is the source code "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");
}
---------------------------------------------------
There is the Makefile:
# standards
INCLUDE = /usr/src/linux/include
CC = gcc
CFLAGS = -D__KERNEL__ -I$(INCLUDE) -DMODULE -Wall -O2
TARGET = hello
SRC = hello.c
all: $(TARGET).o
gcc $(SRC) -c $(TAEGET).o
clean:
rm -f *.o *~ core
---------------------------------------------------
when I run "make" from the terminal, it present like this:
gcc -D__KERNEL__ -I/usr/src/linux/include -DMODULE -Wall -O2 -c -o hello.o hello.c
hello.c:4:26: fatal error: linux/module.h: No such file or directory
compilation terminated.
make: *** [hello.o] Error 1
---------------------------------------------------
I have search this Error from Internet, but unfortunately, I still don't know why...
I'm looking for you help now...
Please type with Chinese directly, I can certainly understand what you will say.
Thank you for your time.