-   Linux - Software (
-   -   compile module for running kernel (

maenho 12-23-2004 04:04 PM

compile module for running kernel

I would like to compile a module, that I initially forgot, to my running 2.6.9 kernel. My first idea was to rebuild the entire kernel so I did make mrproper and clean so I no longer have the compiled version of my kernel. Before installing the new kernel I was thinking that I also had to recompile my nvidia, vmware and cisco vpn kernel modules and decided to keep my existing kernel. Simply compiling the necessary module to the righ place in /lib/modules/... unfortunately gives me:

FATAL: Error inserting snd_intel8x0m (/lib/modules/2.6.9/kernel/sound/pci/snd-intel8x0m.ko): Invalid module format

and dmesg: snd_intel8x0m: disagrees about version of symbol struct_module

since the running kernel and the new module are both from the 2.6.9 source it must have something to do with the buidl number of the kernel or something

Can somebody tell me how I can build this module so with the correct version numbers for the running kernel?

mjrich 12-23-2004 04:47 PM

Do you have the exact matching kernel sources/headers installed for whatever kernel you happen to be running ? Redhat et al. often have unusual flavours that you'll have to get the sources for from one of their mirrors, rather then



lasindi 12-23-2004 08:14 PM

Maenho said 2.6.9, so it's almost certainly a vanilla kernel.

You shouldn't have to recompile these separate modules until you boot the new kernel. Just compile and install the new kernel, then reboot into the new kernel, and install extra drivers/modules.


maenho 12-24-2004 02:56 AM

indeed it's a plain vanilla kernel. The sources for the running kernel are the exact same ones I used for compiling the module. In fact I used the same source tree, did make mrproper, make clean and compiled exactly the same kernel as the one that is running but added the extra module in the .config. I thought I could just copy the extra module to the right location, run depmod and modprobe the new module into the running kernel, this way avoiding to install the new kernel and the hassle of searching the nivida, vmware, cisco vpn installers.

I think the error comes from the fact that 'module versioning' is turned on in the running kernel. I read somewhere this means that all version numbers of the kernel (including build number) have to be the same for both kernel and module. I was hoping that there was a way to compile the module specifically for the running kernel (with the exact version numbers) since that's what the nvidia or vmware installers seem to do.

lasindi 12-24-2004 03:33 AM

You shouldn't have to make clean or anything if you just want to recompile the kernel. All you do is probably waste time. No point in recompiling stuff you've already compiled.

Every kernel module has to be compiled for the specific kernel, i.e., 2.6.9 build 2 will not be able to run with a module form 2.6.9 build 1. I know that every time I recompile my kernel, I have to reinstall the NVIDIA video driver (this is the only driver that's not built into the kernel that I use). And 'module versioning' ought to have nothing to do with this. I don't have it enabled, and I still have to reinstall nvidia everytime. You shouldn't be able to compile for the running kernel unless the sources on the hard drive are unmodified from when you booted it.


jarod 06-27-2005 02:44 PM

I have a similar problem, but with a 2.4 series kernel (2.4.26). I'm trying to compile ip_gre.c as a module. I did

gcc -D__KERNEL__ -I/lib/modules/2.4.26/build/include -DMODULE -Wall -O2  -c -o ip_gre.o ip_gre.c
but got lots of errors:

In file included from ip_gre.c:16:
/lib/modules/2.4.26/build/include/linux/sched.h:807: error: conflicting types for `kernel_thread'
/usr/include/asm/processor.h:432: error: previous declaration of `kernel_thread'
In file included from /lib/modules/2.4.26/build/include/linux/skbuff.h:26,
                from ip_gre.c:19:
/lib/modules/2.4.26/build/include/linux/mm.h:379:1: warning: "page_address" redefined
In file included from /lib/modules/2.4.26/build/include/linux/mm.h:26,
                from /lib/modules/2.4.26/build/include/linux/skbuff.h:26,
                from ip_gre.c:19:
/usr/include/asm/pgtable.h:270:1: warning: this is the location of the previous definition
In file included from /lib/modules/2.4.26/build/include/net/checksum.h:33,
                from ip_gre.c:38:
/usr/include/asm/checksum.h:72:30: missing terminating " character
In file included from /lib/modules/2.4.26/build/include/net/checksum.h:33,
                from ip_gre.c:38:
/usr/include/asm/checksum.h: In function `ip_fast_csum':
/usr/include/asm/checksum.h:73: error: parse error before "movl"
/usr/include/asm/checksum.h:75:17: invalid suffix "f" on integer constant
/usr/include/asm/checksum.h:82:17: invalid suffix "b" on integer constant
/usr/include/asm/checksum.h:90:13: missing terminating " character
/usr/include/asm/checksum.h:105:17: missing terminating " character
/usr/include/asm/checksum.h: In function `csum_fold':
/usr/include/asm/checksum.h:106: error: parse error before "addl"
/usr/include/asm/checksum.h:108:17: missing terminating " character
/usr/include/asm/checksum.h:121:13: missing terminating " character
/usr/include/asm/checksum.h: In function `csum_tcpudp_nofold':
/usr/include/asm/checksum.h:122: error: parse error before "addl"
/usr/include/asm/checksum.h:126:9: missing terminating " character
/usr/include/asm/checksum.h:128: error: `__x' undeclared (first use in this function)
/usr/include/asm/checksum.h:128: error: (Each undeclared identifier is reported only once
/usr/include/asm/checksum.h:128: error: for each function it appears in.)
/usr/include/asm/checksum.h: At top level:
/usr/include/asm/checksum.h:128: error: parse error before ')' token
/usr/include/asm/checksum.h:161:17: missing terminating " character
/usr/include/asm/checksum.h: In function `csum_ipv6_magic':
/usr/include/asm/checksum.h:162: error: parse error before "addl"
/usr/include/asm/checksum.h:173:17: missing terminating " character
/usr/include/asm/checksum.h:176: error: `__x' undeclared (first use in this function)
/usr/include/asm/checksum.h: At top level:
/usr/include/asm/checksum.h:176: error: parse error before ')' token
/usr/include/asm/checksum.h:176: error: parse error before "__u32"
make: *** [ip_gre.o] Error 1

Seeing that the easy way won't do it, I tried the hard way:

make mrproper; make menuconfig (setting gre tunneling to M); make dep; make clean; make bzImage; make modules
Then I try

insmod ip_gre
but I get:

/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol __dev_get_by_name_Rsmp_89306b80
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol netdev_finish_unregister_Rsmp_92f02b33
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol __ip_select_ident_Rsmp_6aab02db
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol __dev_get_by_index_Rsmp_528af64b
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol __write_lock_failed
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol __kfree_skb_Rsmp_9ff9ebf4
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol inet_del_protocol_Rsmp_35227ee6
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol skb_checksum_Rsmp_54602e1e
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol netif_rx_Rsmp_ad8f73a2
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol csum_partial_Rsmp_9a3de8f8
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol sysctl_ip_default_ttl_Rsmp_f6388c56
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol irq_stat_Rsmp_a18a615a
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol ip_finish_output_Rsmp_f87694fd
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol register_netdev_Rsmp_0ac6d484
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol icmp_send_Rsmp_99af1722
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol inet_add_protocol_Rsmp_b0a15bc8
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol sprintf_Rsmp_1d26aa98
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol skb_realloc_headroom_Rsmp_85881137
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol __read_lock_failed
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol unregister_netdev_Rsmp_74922a21
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol printk_Rsmp_1b7d4074
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol kfree_Rsmp_037a0cba
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol netdev_state_change_Rsmp_640e72c5
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol skb_under_panic_Rsmp_9d22b4db
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol ip_route_output_key_Rsmp_2100b1e0
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol sock_wfree_Rsmp_1736bd0e
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol kmalloc_Rsmp_93d4cfe6
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol do_softirq_Rsmp_f0a529b7
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol ip_send_check_Rsmp_a37b7441
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol __pskb_pull_tail_Rsmp_2769b848
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol jiffies_Rsmp_0da02d67
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol ip_fragment_Rsmp_954822be
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol unregister_netdevice_Rsmp_549cff3b
/lib/modules/2.4.264/kernel/net/ipv4/ip_gre.o: unresolved symbol register_netdevice_Rsmp_a7085730

Can anyone make any sense of this?

All times are GMT -5. The time now is 10:48 AM.