Re: driver.develop:error: redefinition of '__inittest'
- From: Janaka <janakas@xxxxxxxxxxxx>
- Date: Thu, 13 Mar 2008 15:53:06 -0700 (PDT)
On Mar 13, 6:13 pm, J CC <east...@xxxxxxxxx> wrote:
hi all,
I wrote the code according to the "Oreilly.linux.device.drivers.
3rd.edition", but when i compiled it, I got the error message below:
localhost test_c_driver # make
Building module...
make[1]: Entering directory `/usr/src/linux-2.6.23-gentoo-r3'
CC [M] /home/xxxx/src/test_c_driver/main.o
/home/xxxx/src/test_c_driver/main.c:18: error: redefinition of
'__inittest'
/home/xxxx/src/test_c_driver/main.c:17: error: previous definition
of '__inittest' was here
/home/xxxx/src/test_c_driver/main.c: In function '__inittest':
/home/xxxx/src/test_c_driver/main.c:18: warning: return from
incompatible pointer type
/home/xxxx/src/test_c_driver/main.c: At top level:
/home/xxxx/src/test_c_driver/main.c:18: error: redefinition of
'init_module'
/home/xxxx/src/test_c_driver/main.c:17: error: previous definition
of 'init_module' was here
make[2]: *** [/home/xxxx/src/test_c_driver/main.o] Error 1
make[1]: *** [_module_/home/xxxx/src/test_c_driver] Error 2
make[1]: Leaving directory `/usr/src/linux-2.6.23-gentoo-r3'
make: *** [main] Error 2
Codes:
1 #include <linux/init.h>
2 #include <linux/module.h>
3
4 MODULE_LICENSE("Dual BSD/GPL");
5
6 static int __init main_init(void)
7 {
8 printk(KERN_ALERT "hello, world\n");
9 return 0;
10 }
11
12 static void __init main_exit(void)
13 {
14 printk(KERN_ALERT "Goodbye, cruel world\n");
15 }
16
17 module_init(main_init);
18 module_init(main_exit);
Makefile:
1 KERNEL_VERSION :=2.6.23-gentoo-r3
2 KERNEL_DIR :=/lib/modules/2.6.23-gentoo-r3/build
3
4 PWD := $(shell pwd)
5
6 obj-m := main.o
7
8 all: main
9
10 main:
11 @echo "Building module..."
12 @(cd $(KERNEL_DIR) && make -C $(KERNEL_DIR) SUBDIRS=$(PWD)
modules)
13
14 clean:
15 -rm -f *.o *.ko .*.cmd .*.flags *.mod.c Modules.symvers
16 -rm -rf .temp_versions
What's the problem? Any suggestion will be appreciated!
Your KERNEL_DIR in your make file seems to be wrong. KERNEL_DIR
should be a root of a kernel source code tree. It seems to be
pointing at the modules directory for your kernel loadable modules.
.
- References:
- Prev by Date: Re: How to detect the change of interface address in the socket programming?
- Next by Date: excessive swap-in time
- Previous by thread: driver.develop:error: redefinition of '__inittest'
- Next by thread: How to detect the change of interface address in the socket programming?
- Index(es):
Relevant Pages
|