Rename your module.c as first.c and modify your Makefile as follows ----------------- ifneq ($(KERNELRELEASE),) obj-m := module.o module-objs += first.o extra.o else KDIR := /lib/modules/$(shell uname -r)/build PWD := $(shell pwd) all: $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules endif ------------------- Now "make", it will create module.ko, which you can safely "insmod" Hope this will help Regards Suneesh --- Sascha Effert <fermat@xxxxxxxxxxxxxxxx> wrote: > Hello, > > I am trying to port a module written for the 2.4 > Kernels to 2.6 Kernels. > One of my first step was to use the kernel-build > system. Following the > Documentation of the makefiles in > Documentation/kbuild/makefiles.txt I > wrote following Makefile: > > ----start Makefile---- > ifneq ($(KERNELRELEASE),) > obj-m := module.o > module-objs += extra.o > > else > KDIR := /lib/modules/$(shell uname -r)/build > PWD := $(shell pwd) > > all: > $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules > > endif > ----end Makefile---- > > This Makefile should compile module.c and extra.c > and link them to one > object. So I wrote two .c-files. First the module.c: > > ----start module.c---- > #include <linux/version.h> > #include <linux/init.h> > #include <linux/module.h> > #include <linux/kernel.h> > #include <linux/config.h> > #include <linux/sysctl.h> > #include <linux/devfs_fs_kernel.h> > #include <linux/proc_fs.h> > > int test_int = 0; > > void test_function(void) { > return ; > } > > static int __init mymodule_init (void) { > printk (KERN_INFO "module starts\n"); > return (0); > } > > static void __exit mymodule_exit (void) { > printk(KERN_INFO "module ends\n"); > return; > } > > module_init(mymodule_init); > module_exit(mymodule_exit); > > MODULE_LICENSE("GPL"); > > EXPORT_SYMBOL (test_function); > EXPORT_SYMBOL (test_int); > ----end module.c---- > > and a extra.c which uses the test_function and > test_int defined and > exportet in module.c: > > ----start extra.c---- > extern void test_function(void); > extern int test_int; > > void try_this(void) { > test_function(); > test_int++; > return; > } > ----end extra.c---- > > So I thought that try_this would use the > test_function defined and > exportet in module.c. But compiling the function > results in following > output: > > ----start output---- > formate@albana:~/imt/VDrive/test> make > make -C /lib/modules/2.6.8-24.10-default/build > > SUBDIRS=/afs/uni-paderborn.de/user/f/fermat/VDrive/test > modules > make[1]: Entering directory > `/usr/src/linux-2.6.8-24.10-obj/i386/default' > make -C ../../../linux-2.6.8-24.10 > O=../linux-2.6.8-24.10-obj/i386/default > modules > CC [M] > /afs/uni-paderborn.de/user/f/fermat/VDrive/test/extra.o > LD [M] > /afs/uni-paderborn.de/user/f/fermat/VDrive/test/module.o > Building modules, stage 2. > MODPOST > *** Warning: "test_function" > > [/afs/uni-paderborn.de/user/f/fermat/VDrive/test/module.ko] > undefined! > *** Warning: "test_int" > > [/afs/uni-paderborn.de/user/f/fermat/VDrive/test/module.ko] > undefined! > LD [M] > /afs/uni-paderborn.de/user/f/fermat/VDrive/test/module.ko > make[1]: Leaving directory > `/usr/src/linux-2.6.8-24.10-obj/i386/default' > formate@albana:~/imt/VDrive/test> > ----end output---- > > I do not understand the two Warnings. Why are > test_function and > test_init undefined? What is wrong? > > I would be pleased if someone could help me. > > > > thanks for your time, > > > Sascha Effert > > > -- > Kernelnewbies: Help each other learn about the Linux > kernel. > Archive: > http://mail.nl.linux.org/kernelnewbies/ > FAQ: http://kernelnewbies.org/faq/ > > __________________________________ Do you Yahoo!? All your favorites on one personal page ? Try My Yahoo! http://my.yahoo.com -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/