On Mon, 6 Dec 2004 11:05:40 +0100, Fabio <fmdf@xxxxxxxxxx> wrote: > [root@localhost modules]# insmod hello-2.ko > insmod: error inserting 'hello-2.ko': -1 Invalid module format > > I've searched Google but I don't find any solution. > > The Makefile is (I've compiled with only typing "make"): > > KDIR:=/lib/modules/$(shell uname -r)/build > > obj-m += hello-1.o > obj-m += hello-2.o > obj-m += hello-3.o > > default: > $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules > clean: > $(RM) .*.cmd *.mod.c *.o *.ko -r .tmp* > > Can any of you help me, please? What am I missing? > > Thank you all in advance, > > fabio > Hi Fabio, I copied the same program from your email and compiled on my machine, it works without a whimper :-) I'm not a makefile expert, but I think that you're not passing the correct args to gcc when you invoke it in your makefile. Why don't you try compile it from the command line with something like this: gcc -I /usr/src/linux/include -DMODULE -D__KERNEL__ -o hello.o -c hello.c. (Make sure to replace /usr/src/linux/include by whatever makes sense on your system). If it works, then you know for sure that the problem is indeed with the makefile. If you do want a makefile, here's a simple one that I use. Warning: the email client would've probably messed up with the tabs, so you'll have to fix that. ---- snip ---- default: hello SRC := hello.c MODULENAME := hello.ko INCDIR := /usr/src/linux/include CFLAGS := -DMODULE -D__KERNEL__ -DLINUX -Wall hello: $(SRC) gcc $(CFLAGS) -I $(INCDIR) -o $(MODULENAME) -c $(SRC) clean: @ echo "cleaning up" rm -f ./*.o ---- snip ---- Hope this helps! Regards, Karthik. -- There are things known and things unknown, in between lie the Doors -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/