LWN: Comments on "Driver porting: compiling external modules" https://lwn.net/Articles/21823/ This is a special feed containing comments posted to the individual LWN article titled "Driver porting: compiling external modules". en-us Fri, 31 Oct 2025 15:40:36 +0000 Fri, 31 Oct 2025 15:40:36 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net Testing the usb-skeleton.c https://lwn.net/Articles/384693/ https://lwn.net/Articles/384693/ saurabh8189 <div class="FormattedComment"> Thanks for the article I have been following your book for a long time. I am working on usb-skeleton.c driver for the pen(say usb flash drive :)) drive on kernel 2.6.32.<br> I am able to load usb-skeleton module to kernel using insmod but every time I plug-in my pen drive it takes usb-storage module.<br> Due to this I am not able to test my first driver.<br> I asked various forums but got no results now you are the one who guided and can guide<br> Here is a link to my question<br> <a rel="nofollow" href="http://www.linuxforums.org/forum/linux-kernel/161862-how-test-my-usb-skeketon-driver.html">http://www.linuxforums.org/forum/linux-kernel/161862-how-...</a><br> <p> Waiting for the reply!!<br> </div> Mon, 26 Apr 2010 12:54:21 +0000 Driver porting: compiling external modules https://lwn.net/Articles/230492/ https://lwn.net/Articles/230492/ ffo The information is misleading as far as I can judge by the number of posts. Here is my contribution.<br> <p> If your module is made of f1.c f2.c and f3.c then your Makefile should look like:<br> obj-m:= module.o<br> module-objs := f1.o f2.o f3.o<br> <p> you will be able to load your module by insmod ./module.ko.<br> Note that module.o is NOT associated to any .c, it is just the product name of the compilation. <br> <p> Now to take other names, misleading ones...<br> If your module is made of interceptor.c frame.c and packet.c then your Makefile should look like:<br> obj-m:= module.o<br> module-objs := interceptor.o frame.o packet.o<br> or <br> obj-m:= interceptor_module.o<br> interceptor_module-objs := interceptor.o frame.o packet.o<br> <p> <p> if your Makefile is<br> obj-m:= interceptor.o<br> interceptpr-objs := interceptor.o frame.o packet.o<br> <p> it will report a circular depdendency and not compile interceptor.c<br> <p> or<br> <p> obj-m:= interceptor.o<br> interceptor-objs := frame.o packet.o<br> <p> it will NOT compile interceptor.c, produce an interceptor.ko (bad), emit some warnings about undefined references. Trying to load it by insmod will produce errors about unresolved stuff.<br> <p> Again, the name after obj-m does NOT correspond to any .c but to the name of the .ko you want to obtain from make. The fact that it is named with a .o extension is very misleading... it should have been .ko IHMO.<br> <p> This may sound obvious for the kernel development community, but for newbies like me, this is way different!<br> Fri, 13 Apr 2007 22:04:31 +0000 How to compile an external driver using a non-default makefile name? https://lwn.net/Articles/216792/ https://lwn.net/Articles/216792/ Linux_v Hi,<br> <p> I used to be able to compile an external device driver using the command in 2.4 kernel:<br> <p> make -f mymakefile<br> <p> But in 2.6 kernel, the command doesn't work.<br> <p> 1) With this command<br> $(MAKE) -C $(KDIR) M=$(PWD) modules <br> <p> I saw the following error:<br> <p> [root@pgenlx11 platypus]# make -f mymakefile<br> make -C /lib/modules/2.6.11.1/build M=/my-correct-ldd-dir modules <br> make[1]: Entering directory `/usr/src/kernels/linux-2.6.11.1'<br> scripts/Makefile.build:13: /my-correct-ldd-dir/Makefile: No such file or directory<br> make[2]: *** No rule to make target `/my-correct-ldd-dir/Makefile'. Stop.<br> make[1]: *** [_module_/my-correct-ldd-dir] Error 2<br> make[1]: Leaving directory `/usr/src/kernels/linux-2.6.11.1'<br> make: *** [all] Error 2<br> <p> From reading the porting article, I've learnt that the 2.6 kernel build process goes through two passes for building an external device driver. The second pass is where it does the building job. But it looks like it was looking for a default makefile, named Makefile, even though, "-f mymakefile" is given at the make command.<br> <br> 2) with this command<br> $(MAKE) -C $(KDIR) M=$(PWD) -f mymakefile modules <br> <p> I saw this the following error: basically, the build process try to look for mymakefile in the linux source tree, instead of the the dir defined by M=$(PWD). <br> <br> [root@pgenlx11 platypus]# make -f mymakefile<br> make -C /lib/modules/2.6.11.1/build M=/my-correct-ldd-path modules -f mymakefile<br> make[1]: Entering directory `/usr/src/kernels/linux-2.6.11.1'<br> make[1]: mymakefile: No such file or directory<br> make[1]: *** No rule to make target `mymakefile'. Stop.<br> make[1]: Leaving directory `/usr/src/kernels/linux-2.6.11.1'<br> make: *** [all] Error 2<br> <p> 3) case 1, "make -f mymakefile", will work fine if I add the following symbolic link:<br> ln -s mymakefile Makefile<br> <br> I tried this just to test if there is other problem for the make. It's not a solution for me.<br> <p> I saw the linux build script uses "make -f " in some case. it look like it should work in 2.6 as well. What have I missed?<br> <p> Thanks in advance!<br> <p> Tue, 09 Jan 2007 00:27:02 +0000 What about cross-compilation? https://lwn.net/Articles/182127/ https://lwn.net/Articles/182127/ DeferX Tray this<br> make CROSS_COMPILE=ppc_6xx- ARCH=ppc<br> It's work<br> <p> By<br> defer<br> Tue, 02 May 2006 13:59:20 +0000 Driver porting: loading external modules https://lwn.net/Articles/164263/ https://lwn.net/Articles/164263/ nusrath When i load the module using insmod the following error is hown<br> <p> insmod: can't read 'test.ko': Stale NFS file handle<br> <p> where test.c is my module name<br> <p> Please help th an answer<br> Thu, 15 Dec 2005 06:41:04 +0000 What about cross-compilation? https://lwn.net/Articles/159590/ https://lwn.net/Articles/159590/ urs You should call<br> <p> make CROSS_COMPILE=ppc_4xx- -C ...<br> <p> instead of your command<br> <p> CROSS_COMPILE=ppc_4xx- make -C ...<br> <p> which handles make variables differently. See the make manual for details.<br> <p> <p> urs<br> <p> Thu, 10 Nov 2005 22:02:46 +0000 What about cross-compilation? https://lwn.net/Articles/155734/ https://lwn.net/Articles/155734/ msprauve Did anyone develop a resolution to this problem?<br> Fri, 14 Oct 2005 00:02:03 +0000 Driver porting: compiling external modules https://lwn.net/Articles/151784/ https://lwn.net/Articles/151784/ mraviraj We have been using linux 2.4 for the development and recently started supporting 2.6.<br> <p> I need to port our existing makefiles to work with 2.4 and 2.6.<br> <p> while i am trying to use following syntax for 2.4, it is just doing 'make clean' job in linux kernel directory.<br> <p> ifeq ($(KERNELRELEASE),)<br> obj-m := foo.o<br> else<br> KDIR := /linux/kernel/src/v2.4/linux-2.4.31<br> PWD := $(shell pwd)<br> default:<br> $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules<br> endif<br> <p> foo-objs := foo1.o foo2.o<br> <p> Can someone please share their experience in compiling the same source code for 2.4 and 2.6 ?<br> <p> <p> thanks ..<br> Raviraj<br> Wed, 14 Sep 2005 23:45:18 +0000 problem with $(CURDIR) https://lwn.net/Articles/145617/ https://lwn.net/Articles/145617/ qu1j0t3 The GNU make docs say that $(CURDIR), when used with -C, will be the 'new' directory, not the module directory, which would make it incorrect in this situation anyway... I think :-)<br> Sun, 31 Jul 2005 20:42:19 +0000 Hardware vendor supplied modules https://lwn.net/Articles/144710/ https://lwn.net/Articles/144710/ qu1j0t3 IT'S YOUR IMAGINATION<br> Fri, 22 Jul 2005 16:55:25 +0000 unable to use ksyms on 2.6 kernel https://lwn.net/Articles/144002/ https://lwn.net/Articles/144002/ kalou Hi rashminivarthy,<br> <p> your kernel is not module enabled,<br> obviously.<br> <p> <p> Sincere Regards,<br> <p> Olivier<br> Mon, 18 Jul 2005 11:38:09 +0000 Unable to compile external modules in 2.6-9.5 kernel https://lwn.net/Articles/129753/ https://lwn.net/Articles/129753/ muraligadela Hi<br> I am porting simple device driver from 2.4 kernel to 2.6.9-5. I followed the instructions in the "compiling external modules" articles posted in the lwn.net. I am still unable to compile and the compiler errror received is<br> awk: cmd. line:2 fatal: cannot open file `test.h` for reading (no such file or directory). I have added the location of test.h to CFLAGS varaible and also to EXTRA_CFLAGS in the makefile.<br> <p> Any help is appreciated.<br> Wed, 30 Mar 2005 19:31:20 +0000 Driver porting: compiling external modules https://lwn.net/Articles/128654/ https://lwn.net/Articles/128654/ krash To save the uninitiated from pulling too much hair out:<br> <p> In the example:<br> <p> obj-m := module.o<br> module-objs := file1.o file2.o <br> <p> It might be clearer for it to read something like this:<br> <p> obj-m := name-of-module.o<br> name-of-module-objs := file1.o file2.o <br> <p> to stress that in the original module-objs, module is in fact the name of the module. <br> Tue, 22 Mar 2005 17:40:49 +0000 What about cross-compilation? https://lwn.net/Articles/126013/ https://lwn.net/Articles/126013/ mhb I have tried this on the simple hello.c module. <br> I use the ELDK cross compiler to generate code for <br> a ppc 440 from an X86 based machine. It fails <br> with some emulation mode problems, any ideas ? <br> <br> [root@basher ebonymnt]# export CROSS_COMPILE=ppc_4xx- <br> [root@basher ebonymnt]# make -C /home/simon/ebonymnt/linux-2.6.10 M=`pwd` <br> make: Entering directory `/home/simon/ebonymnt/linux-2.6.10' <br> LD /home/simon/ebonymnt/built-in.o <br> CC [M] /home/simon/ebonymnt/hello.o <br> Building modules, stage 2. <br> MODPOST <br> CC /home/simon/ebonymnt/hello.mod.o <br> LD [M] /home/simon/ebonymnt/hello.ko <br> ppc_4xx-ld: unrecognised emulation mode: elf_i386 <br> Supported emulations: elf32ppclinux elf32ppc elf32ppcsim <br> make[1]: *** [/home/simon/ebonymnt/hello.ko] Error 1 <br> make: *** [modules] Error 2 <br> make: Leaving directory `/home/simon/ebonymnt/linux-2.6.10' <br> [root@basher ebonymnt]# <br> <br> <br> Thu, 03 Mar 2005 10:48:11 +0000 Driver porting: compiling external modules https://lwn.net/Articles/122116/ https://lwn.net/Articles/122116/ fleetinglife I built my driver successfully in kernel 2.6.0,<br> BUT when I insmod the .ko file, I got <br> "no module found in object<br> Error inserting 'name.ko' : -1 Invalid module format"<br> <p> Who can tell me, where can I get docs about module format in kernel 2.6.0?<br> Fri, 04 Feb 2005 06:51:54 +0000 Driver porting: compiling external modules https://lwn.net/Articles/121920/ https://lwn.net/Articles/121920/ fleetinglife I see, The module-objs should be modified into file_mod-objs.<br> Thu, 03 Feb 2005 09:30:40 +0000 Driver porting: compiling external modules https://lwn.net/Articles/121894/ https://lwn.net/Articles/121894/ fleetinglife I am struggling to build my first linux driver module.<br> <p> I have four .c files in my source directroy, the file file_mod.c is the one contains the main code of module. I use the Makefile as following:<br> <p> obj-m := file_mod.o<br> module-objs := file1.o file2.o file3.o file_mod.o<br> <p> and type make command as following:<br> <p> make -C /usr/src/linux-2.6.0 SUBDIRS=$PWD modules<br> <p> It can build the file_mod.ko successfully, but I got a list of warning messages, said some functions called in file_mod.ko UNDEFINED! These functions are defined in file1.c, file2.c, file3.c.<br> <p> How to solve this problem? Any suggestion will be appreciated.<br> Thu, 03 Feb 2005 03:28:22 +0000 Driver porting: compiling external modules https://lwn.net/Articles/114976/ https://lwn.net/Articles/114976/ meenaxi hello, <br> <br> First I would like to say Thanks for this article, it was very helpful!! <br> but unfortunately I am still facing some problems. <br> <br> I am running Suse-9.1 Linux kernel and I want to write a loadable module. <br> I tried the helloworld program and it is working just fine, but then i <br> started with a simple character device driver program which is given as <br> example in Linux Module programming guide-2.6. but when i run the make <br> for this the whole make is running without error(there are a few <br> warnings) but the chardev.ko or chardev.o is not formed. i have no idea <br> why???.....any help would be appreciated!! <br> <br> Thanks a dozen <br> meenaxi. <br> Thu, 09 Dec 2004 14:25:19 +0000 Driver porting: compiling external modules https://lwn.net/Articles/112893/ https://lwn.net/Articles/112893/ wuyanmin2 My kernel version is 2.6.5, I complied a "Hello world" module,it's very simple but the size is more than 100K, however, most of the kernel modules in /lib/modules/ are less than 50K . What's the matter? How can I complie a smaller module??<br> <p> Thanks<br> <p> WU Yan-min<br> Fri, 26 Nov 2004 09:44:13 +0000 Driver porting: compiling external modules https://lwn.net/Articles/110286/ https://lwn.net/Articles/110286/ kabbalah thank you for your reply, I tried your code but when i compile it I still get plenty of errors:<br> cc hello.c -o hello<br> In file included from /usr/include/linux/sched.h:12,<br> from /usr/include/linux/module.h:9,<br> from hello.c:2:<br> /usr/include/linux/jiffies.h:16: error: parse error before "jiffies_64"<br> /usr/include/linux/jiffies.h:20: error: parse error before "get_jiffies_64"<br> In file included from /usr/include/linux/sched.h:21,<br> from /usr/include/linux/module.h:9,<br> from hello.c:2:<br> /usr/include/asm/mmu.h:13: error: field `sem' has incomplete type<br> In file included from /usr/include/linux/signal.h:4,<br> from /usr/include/linux/sched.h:25,<br> from /usr/include/linux/module.h:9,<br> from hello.c:2:<br> /usr/include/linux/list.h:604:2: warning: #warning "don't include kernel headers in userspace"<br> In file included from /usr/include/asm/siginfo.h:4,<br> from /usr/include/linux/signal.h:7,<br> from /usr/include/linux/sched.h:25,<br> from /usr/include/linux/module.h:9,<br> from hello.c:2:<br> /usr/include/asm-generic/siginfo.h:53: error: size of array `_pad' is too large<br> In file included from /usr/include/linux/sched.h:27,<br> from /usr/include/linux/module.h:9,<br> from hello.c:2:<br> /usr/include/linux/fs_struct.h:9: error: parse error before "rwlock_t"<br> /usr/include/linux/fs_struct.h:13: error: parse error before '}' token<br> In file included from /usr/include/linux/sched.h:29,<br> from /usr/include/linux/module.h:9,<br> from hello.c:2:<br> /usr/include/linux/completion.h:15: error: parse error before "wait_queue_head_t"<br> /usr/include/linux/completion.h: In function `init_completion':<br> /usr/include/linux/completion.h:26: error: dereferencing pointer to incomplete type<br> /usr/include/linux/completion.h:27: error: dereferencing pointer to incomplete type<br> In file included from /usr/include/linux/sched.h:30,<br> from /usr/include/linux/module.h:9,<br> from hello.c:2:<br> /usr/include/linux/pid.h: At top level:<br> /usr/include/linux/pid.h:18: error: field `task_list' has incomplete type<br> /usr/include/linux/pid.h:19: error: field `hash_chain' has incomplete type<br> /usr/include/linux/pid.h:24: error: field `pid_chain' has incomplete type<br> In file included from /usr/include/linux/module.h:9,<br> from hello.c:2:<br> /usr/include/linux/sched.h:93: error: parse error before "process_counts"<br> In file included from /usr/include/linux/sched.h:102,<br> from /usr/include/linux/module.h:9,<br> from hello.c:2:<br> /usr/include/linux/timer.h:10: error: field `entry' has incomplete type<br> hello.c:22: error: parse error before "__attribute_used__"<br> hello.c:22: warning: initialization makes integer from pointer without a cast<br> hello.c:22: warning: data definition has no type or storage class<br> hello.c:23: error: parse error before "__attribute_used__"<br> hello.c:23: error: redefinition of `__attribute_used__'<br> hello.c:22: error: `__attribute_used__' previously defined here<br> hello.c:23: warning: initialization makes integer from pointer without a cast<br> hello.c:23: warning: data definition has no type or storage class<br> hello.c:23:25: warning: no newline at end of file<br> make: *** [hello] Error 1<br> <p> when i remove the #include &lt;linux/modules.h&gt; directive I get less errors but it still won't compile:<br> cc hello.c -o hello<br> hello.c:6: error: parse error before string constant<br> hello.c:6: warning: data definition has no type or storage class<br> hello.c:22: error: parse error before "__attribute_used__"<br> hello.c:22: warning: initialization makes integer from pointer without a cast<br> hello.c:22: warning: data definition has no type or storage class<br> hello.c:23: error: parse error before "__attribute_used__"<br> hello.c:23: error: redefinition of `__attribute_used__'<br> hello.c:22: error: `__attribute_used__' previously defined here<br> hello.c:23: warning: initialization makes integer from pointer without a cast<br> hello.c:23: warning: data definition has no type or storage class<br> make: *** [hello] Error 1<br> <p> so that makes me pretty much desperate now :)<br> I guess I will have to forget about LKMs till the next Linux I install...<br> anyhow 10x again :)<br> Tue, 09 Nov 2004 21:25:06 +0000 Driver porting: compiling external modules https://lwn.net/Articles/110114/ https://lwn.net/Articles/110114/ madhavi_srinivas Dear Kabbalah,<br> <p> I am using SuSE 9.1 with 2.6.5-7.71 kernel. I have written small hello.c program here. It was working fine on my x86 machine.<br> <p> #include &lt;linux/init.h&gt;<br> #include &lt;linux/module.h&gt;<br> #include &lt;linux/kernel.h&gt;<br> <p> MODULE_LICENSE("GPL");<br> <p> static int hello_init(void)<br> {<br> printk("Hello World!\n");<br> return 0;<br> }<br> <p> static void hello_exit(void)<br> {<br> printk("Good bye!\n");<br> }<br> <p> module_init(hello_init);<br> module_exit(hello_exit);<br> <p> For this the make file is as follows.<br> <p> KDIR:=/lib/modules/$(shell uname -r)/build<br> <p> obj-m:=hello.o<br> <p> default: <br> $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules<br> clean:<br> $(RM) .*.cmd *.o *.ko -r .tmp*<br> <p> It was working fine under x86 machine with 2.6.5-7.71 kernel version with SuSE Linux.<br> <p> Regards,<br> Srinivas G<br> Tue, 09 Nov 2004 10:16:12 +0000 Driver porting: compiling external modules https://lwn.net/Articles/110105/ https://lwn.net/Articles/110105/ kabbalah hi there<br> I installed SuSe 9.1 with 2.6.4-52-default kernel and I'm having some problems writing modules for it.<br> I've read these articles and still can't find the answer....<br> that's my module<br> <p> //#include &lt;linux/module.h&gt; <br> #include &lt;linux/kernel.h&gt; <br> #include &lt;linux/init.h&gt;<br> <p> //MODULE_LICENSE("Dual BSD/GPL");<br> <p> static int module_init(void)<br> {<br> printk("&lt;1&gt;Hello world 1.\n");<br> return 0;<br> }<br> <p> <p> static void module_exit(void)<br> {<br> printk("Goodbye world 1.\n");<br> } <br> <p> and that's the makefile<br> <p> ifneq ($(KERNELRELEASE),)<br> obj-m:= h.o<br> <p> else<br> KDIR:= /lib/modules/$(shell uname -r)/build<br> PWD:= $(shell pwd)<br> <p> default:<br> $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules<br> endif<br> <p> When I compile it I get these<br> h.c:10: error: parse error before "__initcall_void"<br> h.c:10: error: parse error before "void"<br> h.c:19: error: parse error before "__exitcall_void"<br> h.c:19: error: redefinition of `__attribute_used__'<br> h.c:10: error: `__attribute_used__' previously defined here<br> h.c:19: error: parse error before "void"<br> make: *** [h] Error 1<br> <p> any ideas why this happens ?<br> Tue, 09 Nov 2004 00:57:44 +0000 unable to use ksyms on 2.6 kernel https://lwn.net/Articles/108389/ https://lwn.net/Articles/108389/ rashminivarthy hello <br> i tried using ksyms on 2.6 kernel to view all the exported kernel <br> symbols .It gave an error- <br> ksyms: QM_MODULES: Function not implemented <br> <br> plz any 1 reply back <br> Wed, 27 Oct 2004 10:17:48 +0000 Path to the kernel source https://lwn.net/Articles/108381/ https://lwn.net/Articles/108381/ rashminivarthy hello, <br> i was trying to compile a simple helloworld module on linux-2.6 <br> kernel (Fedoracore-2)i'm geting this error while using this <br> makefile <br> --------------- <br> |MakeFile | <br> ---------------- <br> ifneq ($(KERNELRELEASE),) <br> obj-m := hello.o <br> else <br> KDIR := /lib/modules/$(shell uname -r)/build <br> PWD := $(shell pwd) <br> default: <br> $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules <br> endif <br> --------------- <br> |ERROR MESSAGE| <br> ---------------- <br> cc hello.c -o hello <br> hello.c:1:26: linux/module.h: No such file or directory <br> hello.c:2:27: linux/kernel.h: No such file or directory <br> hello.c:3:24: linux/init.h: No such file or directory <br> make: *** [hello] Error 1 <br> <br> Wed, 27 Oct 2004 08:25:44 +0000 Driver porting: compiling external modules with local includes https://lwn.net/Articles/107166/ https://lwn.net/Articles/107166/ amcrae What I'd like to be able to do is set a couple of extra 'include' paths. (I note from earlier articles that setting 'CFLAGS' is .. umm.. discouraged.)<br> <p> I needed to do the same thing. You can do this with the EXTRA_CFLAGS Makefile variable:<br> <p> ...<br> obj-m += file.o<br> EXTRA_CFLAGS += -I$(obj)/../include<br> <p> Cheers,<br> AMc<br> Wed, 20 Oct 2004 05:24:25 +0000 Driver porting: compiling external modules with local includes https://lwn.net/Articles/106723/ https://lwn.net/Articles/106723/ geoff_o I've also been searching for the answer to this question.<br> <p> What I'd like to be able to do is set a couple of extra 'include' paths. (I note from earlier articles that setting 'CFLAGS' is .. umm.. discouraged.)<br> <p> I hope there's a work around, otherwise it makes it difficult to develop modules outside the kernel tree that depend on each other.<br> <p> Does there exist a solution?<br> <p> Thanks,<br> <p> Geoff<br> Fri, 15 Oct 2004 16:48:34 +0000 Driver porting: compiling external modules https://lwn.net/Articles/100644/ https://lwn.net/Articles/100644/ klaus.hitschler@gmx.de I've ported my CAN driver to Kernel 2.6.5 and I'm using the M=$(PWD) switch for making this external module. Now I got this output:<br> <p> make -C /usr/src/linux M=/home/klaus/work/peak/peak-linux-driver/driver V=0 modules<br> make[1]: Entering directory `/usr/src/linux-2.6.5-7.108'<br> CC [M] /home/klaus/work/peak/peak-linux-driver/driver/src/pcan_main.o<br> .... a lot more ...<br> CC [M] /home/klaus/work/peak/peak-linux-driver/driver/src/pcan_usb.o<br> LD [M] /home/klaus/work/peak/peak-linux-driver/driver/pcan.o<br> Building modules, stage 2.<br> MODPOST<br> Warning: could not find versions for .tmp_versions/pcan.mod<br> CC /home/klaus/work/peak/peak-linux-driver/driver/pcan.mod.o<br> LD [M] /home/klaus/work/peak/peak-linux-driver/driver/pcan.ko<br> make[1]: Leaving directory `/usr/src/linux-2.6.5-7.108'<br> <p> I wondered about the line <br> "Warning: could not find versions for .tmp_versions/pcan.mod". <br> Some investigation shows that in my $(PWD) a directory .tmp_versions was created and the pcan.mod was stored in that directory. For any strange reason a part of modpost "sumversions.c" is looking for .tmp_versions/pcan.mod located at the base of the kernel source tree. The same happens with the SUBDIRS=$(PWD) syntax.<br> <br> Does anyone have an idea what' wrong?<br> <p> P.S. pcan.ko is generated and is works perfectly.<br> <p> Klaus<br> Thu, 02 Sep 2004 20:30:59 +0000 SUBDIRS= vs M= https://lwn.net/Articles/99465/ https://lwn.net/Articles/99465/ r2b2lewis I am running on SuSE 9.1 (2.6.4-52-smp).<br> <p> When I ran the make file using the line:<br> <p> $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules<br> <p> the make ran quickly without error.<br> <p> However, when I changed that line to:<br> <p> $(MAKE) -C $(KDIR) M=$(PWD) modules<br> <p> I seem to be making the entire kernel again.<br> <p> What's up with that?<br> Thu, 26 Aug 2004 17:10:25 +0000 Driver porting: compiling external modules https://lwn.net/Articles/99122/ https://lwn.net/Articles/99122/ cidis I'm porting driver for Pent@value card, but I dont have all sources. Some modules are already compiled. Can I link all together? How?<br> Tue, 24 Aug 2004 18:05:40 +0000 Driver porting: compiling external modules with local includes https://lwn.net/Articles/97194/ https://lwn.net/Articles/97194/ cpp9999 I'm having trouble compiling an external module under the following dir structure<br> A local header file sits in a directory other than the one that contains the main file<br> See below:<br> home_dir/dirA/local.h<br> home_dir/dirB/main.c<br> <p> sample main.c file<br> #include "dirA/local.h"<br> main ()<br> {<br> /* some code */<br> }<br> <p> # make -C /usr/src/linux-2.6.7 SUBDIRS=$(PWD) modules<br> When I try to compile I get the following error messages<br> Entering directory /usr/src/linux-2.6.7<br> CC [M] /home_dir/dirB/main.c:15:32: dirA/local.h: No such file or directory<br> <p> Obviously when I am in /usr/src/linux-2.6.7 I cannot see local.h.<br> <p> Any ideas how to fix this? Thanks<br> <p> Mon, 09 Aug 2004 21:22:42 +0000 Driver porting: compiling external modules https://lwn.net/Articles/95155/ https://lwn.net/Articles/95155/ anikami1 I have the following problem with a device driver. It will load in my machine, but if I try to load it under a different kernel version, or on another machine with a different kernel version, I get &quot;invalid module format&quot; errors. I am pretty sure this has to do with the &quot;version magic&quot; feature of the 2.6.X kernels.<p>My question is, do I need to compile the module/driver under EACH kernel version out there? Is there a way to compile the module so that it loads on any machine with a 2.6.X kernel? Mon, 26 Jul 2004 17:37:15 +0000 Multi-file modules--help! https://lwn.net/Articles/95051/ https://lwn.net/Articles/95051/ amishdave I think you need to replace module-objs with foo-objs...<br> Sun, 25 Jul 2004 17:09:22 +0000 Driver porting: compiling external modules https://lwn.net/Articles/94961/ https://lwn.net/Articles/94961/ Ryu_Tenchi *^^* thank you, i feel stupid now lol, but it works and I learned from it <br>so,thanks again^_^ Fri, 23 Jul 2004 23:54:14 +0000 Multi-file modules--help! https://lwn.net/Articles/94912/ https://lwn.net/Articles/94912/ ajnicholson I have an external module comprised of 3 .c files...<p>I made the following Makefile:<br>----------------------------------<br>obj-m := foo.o<br>module-objs := file1.c file2.c file3.c<br>-----------------------------------<p>yet when I compile it by running:<br>make -C /usr/src/linux SUBDIRS=$PWD modules<p>It issues the following error:<br>make[2]: *** No rule to make target '/usr/src/foo.c', needed by '/usr/src/foo/foo.o'. Stop.<p>Any ideas? I thought the &quot;module-objs&quot; line was supposed to indicate which files comprise the complete module... Fri, 23 Jul 2004 19:04:07 +0000 Driver porting: compiling external modules https://lwn.net/Articles/94697/ https://lwn.net/Articles/94697/ disq apparently it's &quot;obj-m&quot;, not &quot;objs-m&quot;<br> Thu, 22 Jul 2004 15:00:00 +0000 Driver porting: compiling external modules https://lwn.net/Articles/93663/ https://lwn.net/Articles/93663/ Ryu_Tenchi i'm a little lose so sorry for this, but i'm trying to figure this stuff out but it never actually make the module...<br>code:<br>//main.c<br>#include &lt;linux/module.h&gt;<br>#include &lt;linux/config.h&gt;<br>#include &lt;linux/init.h&gt;<p>int init_module(void){printk(&quot;&lt;1&gt;Hello, world\n&quot;); return 0;}<br>void cleanup_module(void) {printk(&quot;&lt;1&gt;Goodbye cruel world\n&quot;);}<p>makefile:<br>objs-m := main.o<p>command entered:<br>make -C /usr/src/linux M=`pwd` modules<p>output:<br>make: Entering directory `/usr/src/linux-2.6.7-gentoo-r11'<br> Building modules, stage 2.<br> MODPOST<br>make: Leaving directory `/usr/src/linux-2.6.7-gentoo-r11'<p>any help would be great, thanks^_^ Thu, 15 Jul 2004 06:12:05 +0000 SUBDIRS= vs M= https://lwn.net/Articles/93242/ https://lwn.net/Articles/93242/ corbet You found the current way of doing things; the article is mildly out of date. I'll fix it, but, since the old scheme continues to work, it's not been my top priority... Mon, 12 Jul 2004 13:54:38 +0000 SUBDIRS= vs M= https://lwn.net/Articles/93204/ https://lwn.net/Articles/93204/ kcannon <p>The 2.6.7 Makefiles say that an external module should be compiled by setting the variable M to the directory in which the module resides, rather than by setting SUBDIRS.&#160; The command line is</p> <p>$ make -C /path/to/kernel/source M=/path/to/your/module modules</p> <p>I've confirmed that this does work.&#160; What is the reason for choosing one over the other?&#160; Are they synonyms?</p> Mon, 12 Jul 2004 02:26:41 +0000 Driver porting: compiling external modules https://lwn.net/Articles/93203/ https://lwn.net/Articles/93203/ kcannon Never mind... my mistake. You replace the default value of PWD with the result of $(shell pwd). Mon, 12 Jul 2004 02:20:27 +0000 Driver porting: compiling external modules https://lwn.net/Articles/93155/ https://lwn.net/Articles/93155/ kcannon It's probably better to use $(CURDIR) in the Makefile rather than $(PWD). $(PWD) is set to the directory from which the original make command was issued, while $(CURDIR) is set to the current working directory (eg. as modified by recursive use of make -C). If the driver modules are distributed in a subdirectory of a larger software package, and the user is intended to issue a make command from the top-level directory, using $(PWD) in the driver Makefile will pick up the wrong path.<p>Cheers<br>-Kipp Sun, 11 Jul 2004 06:23:23 +0000