Re: Insmod problems

Tommy Reynolds (reynolds@redhat.com)
Tue, 4 Dec 2001 12:33:27 -0600


--=.kkvF.Z2SZ.76XE
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

More important activities lacking, "Michael Zhu" <apiggyjj@yahoo.ca> wrote:

> I've changed my source file like this:
> #define MODULE
>
> #include <linux/module.h>
>
> int init_module(void) { printk("<1>Hello, world\n");
> return 0; }
> void cleanup_module(void) { printk("<1>Goodbye cruel
> world\n"); }
>
> And I use the following command line to build the
> module.
>
> gcc -c -D__KERNEL__ hello.c
>
> But when I use insmod to load the module I got the
> following error message:
>
> hello.o : kernel-module version mismatch
> hello.o was compiled for kernel version
> 2.4.12
> while this kernel is version 2.4.8
>
> What is wrong? My kernel version is 2.4.8. Is there
> something wrong with the gcc compilier? My gcc
> compilier is gcc-2.95.

You're not picking up the correct kernel header files. Don't allow GCC to pick
up the files from "/usr/include/linux":

$ gcc -I/usr/src/linux/include -c -D__KERNEL__ hello.c

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + -- -- -- -- -- -- -- -- -- --
Tommy Reynolds | mailto: <reynolds@redhat.com>
Red Hat, Inc., Embedded Development Services | Phone: +1.256.704.9286
307 Wynn Drive NW, Huntsville, AL 35805 USA | FAX: +1.256.837.3839
Senior Software Developer | Mobile: +1.919.641.2923

--=.kkvF.Z2SZ.76XE
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)

iEYEARECAAYFAjwNFvsACgkQWEn3bOOMcuoESQCfYAgd4aEKWdTf06q+96GnslFb
4hcAoLjUUxoR4cjBqnmgzWDXoBXzlwll
=GHyE
-----END PGP SIGNATURE-----

--=.kkvF.Z2SZ.76XE--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/