Problems compiling module out of the kernel

Problems compiling module out of the kernel

Post by Michael Heimin » Wed, 25 Jun 2003 17:33:54


due to the fact that the last RH kernel update broke the binary only raid tool
'dellmgr', because of changes in mgearaid.c, I compiled a fixed version of the
module. It works but I get this *:

# depmod -a
depmod: *** Unresolved symbols in /lib/modules/2.4.20-18.7smp/kernel/drivers/scsi/megaraid.o

Compiled like this:

# gcc -D__SMP__ -DMODULE -D__KERNEL__ -Wall -Wstrict-prototypes -O2 -c \
-I/usr/src/linux-2.4.20-18.7/drivers/scsi -I/lib/modules/2.4.20-18.7smp/build/include \
-I/lib/modules/2.4.20-18.7smp/build -I/usr/src/linux/drivers/scsi megaraid.c \
`[ -f /usr/include/linux/modversions.h ] && echo -DMODVERSION`

install -m 644 megaraid.o /lib/modules/2.4.20-18.7smp/kernel/drivers/scsi

The same happens with the original megaraid.c from the RH kernel source, so it looks
like a problem with my compile options, not with megaraid.c

Thx for hints to get it working

Michael Heiming

Remove +SIGNS and www. if you expect an answer, sorry for
inconvenience, but I get tons of SPAM


1. Redhat 5.1 - ANSWERS - compile kernel, modules, /lib/modules/preferred

Especially when I start out, I like to keep around
a bunch of kernels.  Some with sound compiled in,
some without, some as a module.  And whatever else
I am working on.  Unfortunately, redhat 5.1 does things
in a strange way, which means that I got very confused
about problems relating to modules.

Here's what it does:  At boot-up, the system does the
equivalent of   cat /proc/version   to find out the
version of the kernel being used, which is a fairly long
string of characters.  It then looks for that string
to be in a file in /lib/modules/2.0*/.rhkmvtag .
That is THE MOST IMPORTANT FILE in the modules
directory, and it IS NOT GENERATED.  Can you say
"serious design flaw"?  I knew you could.
It uses this info to figure out where to point
/lib/modules/preferred and /boot/

At the end of this message I include a [poor] script that
does what needs to be done.  It should be run in the
directory where you make the kernel.  It should really
be part of the "make modules_install".  I encourage
people who know what they are doing to improve it, add
error-checking, etc., or ideally figure a patch to the Makefile.

Before we get there, let me remark that sound.o is a very
special module.  When I upgraded to redhat kernel sources
and headers 2.0.35-7, I could no longer compile it.  Be
very careful.  Also, see other posts about fixes for
net-pf-4 errors, basically you turn them off in the
file /etc/conf.modules with the two lines
alias net-pf-4 off
alias net-pf-5 off

The following script was what I used to create the new
kernel I think of as soundmod (for sound as a module).
The only trick is to use "strings" on init/version.o
to find out the full version name of the kernel.

Oh - and for those who ask how to save the old kernel,
the trick is not to overwrite it!  It is that simple. :)
Keep around several until you pick the one you like best.

Eddie Grove

please feel free to copy, modify, and propogate a better
version of this!  If it helps you, let me know it was
worth the trouble to post.


# should check that does not already exist
# note that initial redhat installation has NEWNAME=1

cd /usr/src/linux

make zImage
cp .config /boot/config-$VERSION-$NEWNAME
# It makes sense to save the config file used to build the kernel
cp arch/i386/boot/zImage /boot/vmlinuz-$VERSION-$NEWNAME

make modules
make modules_install
strings init/version.o | grep version > /lib/modules/$VERSION/.rhkmvtag
mv /lib/modules/$VERSION /lib/modules/$VERSION-$NEWNAME

echo "Don't forget to modify /etc/lilo.conf"

2. Jumpy mouse cursor in X

3. Compiling the kernel: to module or not to module?

4. Solaris2.6 fails to boot with SUN SBus cards!

5. Compiling 2.4.2 kernel on RH7 with compiled modules

6. How to check the presence of 8251/uPD71051 uart ?

7. Compiling modules without compiling kernel

8. Gnome on Slackware 8.0 Configuration Problem

9. how to compile the IPv6 module without compiling the whole kernel?

10. Help: Kernel module doesn't compile after kernel upgrade.

11. Kernel 2.4.8 - EMU10K1 - Kernel Compile Breaks in Module main.o

12. "module-info,kernel.h," after compiling kernel?

13. Newbie Help: Module compiled for kernel 4.2.0 kernel is 4.2.0-4GB ??