Pick a Free OS

User login


Kernel Compilation & Avoiding ‘Unresolved Symbol’

bash# /sbin/lilo

If ‘Grub’ is the bootloader

In /etc/grub.conf add the following

title Red Hat Linux (2.4.18-

root (hd0,8)

kernel /boot/bzImage ro root=/dev/hda1

Following is optional

Dumping the boot image to a floppy with the following command

bash#cat bzImage > /dev/fd0

Important Tip:

Instead of using kernel sources which comes with the distribution CD's.

It is always better to download the latest kernel from kernel.org. The reason being the kernel sources in the distribution CD's are altered and in many cases it has been found that some header files were missing or they were of the older versions

Avoiding Unresolved Symbols /Version mismatch Errors

Most of the kernel newbie’s are intimidated by the Unresolved symbols / Version mismatch errors which they face when trying to compile and 'insmod' there newly compiled kernel modules.

The reasons for this error:

Though there are many reasons , the most common reason is

Kernel and modules are compiled with different modversion information.

Now you might get a doubt what is this modversion! Every kernel module created consists of information about the kernel version on which it is compiled, for instance if module X is compiled on kernel 2.4.18 and if you are trying to run this module X on a kernel whose version is 2.4.22 then there will be a mismatch of module versions.

How to avoid this Problem

Add the following at the starting to the kernel module source file you are creating.

#if defined __KERNEL__


#if defined( CONFIG_MODVERSIONS ) && ! defined( MODVERSIONS )



/* modversions.h should be before should be before module.h */

#if defined( MODVERSIONS )





/* Now your module include files & source code follows */

Apart from the above you should compile your module with the following compiler flags.

For instance if your module name is xyz.c then

bash#gcc -I/lib/modules//build/include -

D__KERNEL__ -DMODULE -DLINUX -O2 -Wall -Wstrict-prototypes

-fno-strict-aliasing -fno-strict-aliasing -c -o xyz.o xyz.c

Substitute the above with the kernel version name you are currently using. You can know that with the following command.

Bash# uname –r