LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Compiling kernel modules (https://www.linuxquestions.org/questions/linux-kernel-70/compiling-kernel-modules-437107/)

andrugene 04-20-2006 08:40 AM

Compiling kernel modules
 
Hi!
Now that you guys have this kernel thingy, i was wondering whether you could help me understand the error messages i get when trying to compile a kernel module. It seems like the kernel Header files have errors in them. Are there clean headers i could use or what?

Thanx.

rick.2g 04-20-2006 12:11 PM

well... it depends on what kind of errors you're getting. If you're getting warnings, then it's usually nothing to worry about - if you're getting a failed compile, then it might be bad dependencies; do you have the output with the errors?

notorp 04-20-2006 12:53 PM

I've noticed that kernel 2.6.16 doesn't like to build modules! Can't get fglrx to build and seen a few threads with the same. What kernel version are you using

notorp 04-20-2006 06:48 PM

Scratch that just updated to 2.6.16.2096 (2.6.16-1.2096_FC4smp) from 2.6.16.2069 and now able to compile modules again. Have got fglrx to work even if not using the ati agp.

sajjadc 04-26-2006 01:58 PM

ok
goood reply
thanx

/bin/bash 04-27-2006 03:15 AM

Quote:

i was wondering whether you could help me understand the error messages i get when trying to compile a kernel module.
No. We can't help unless you post the error message.

akanitkar 05-06-2006 12:34 AM

hi,
i am new to linux. When I try to insert object file into kernel using insmod, I get message like kernel version mismatch. I am using red hat 9, kernel version 2.4.20-8 and gcc 3.2.2. what should i do ?
Regards,
Aditya

GlennsPref 05-06-2006 06:47 AM

Akanitkar, To get a faster response, You should post a new thread with your question.

Kind regards, Glenn

btw, That is called hijacking a thread, and when ppl log on to this forum, they won't see your question

the_unforgiven 05-07-2006 01:46 AM

Quote:

Originally Posted by akanitkar
hi,
i am new to linux. When I try to insert object file into kernel using insmod, I get message like kernel version mismatch. I am using red hat 9, kernel version 2.4.20-8 and gcc 3.2.2. what should i do ?
Regards,
Aditya

Well, since you're compiling something related to kernel, you've gotta compile it with the kernel headers and not glibc headers.
So, your compile command should look like:
gcc -c hello.c -o hello.o -I /usr/src/linux-2.4.20-8/include -D__KERNEL__

Adapt the command to suite your configuration. ;)
HTH ;)

m.anju 06-24-2006 05:19 AM

Compiling Kernel Module
 
[QUOT:E=the_unforgiven]Well, since you're compiling something related to kernel, you've gotta compile it with the kernel headers and not glibc headers.
So, your compile command should look like:
gcc -c hello.c -o hello.o -I /usr/src/linux-2.4.20-8/include -D__KERNEL__

Adapt the command to suite your configuration. ;)
HTH ;)[/QUOTE]


hi,

I tried this, but still error

" couldn't find the kernel version the module was compiled for"

thanx

m.anju 06-24-2006 05:24 AM

hi,
I m new to linux i am trying kernel programming while insertion of mod error comes when i tried the command

#gcc -c hello.c -o hello.o -isystem /usr/src/linux-2.4.20-8/include -D__KERNEL__ -DLINUX

error: couldn't find the kernel version the module was compiled for

then instead of -isystem i tried -I the problem is not yet solved

Thanx

sundialsvcs 06-24-2006 07:56 AM

Kernel modules should be rebuilt by using make in the /usr/src/linux directory. I don't see any value in trying to compile them "by hand."

Each kernel module contains a version-identifier designed specifically to prevent them from being loaded by a kernel other than the one they were built for. (Obviously, this would mean instant death. :jawa: )

If you are running on binary "distros," and are not compiling things for your own kernel, then you simply need to find the right version of "the package or RPM or whatever" that contains the binary module corresponding to the kernel you now have installed.

If you are running on a kernel that you compile yourself, from source, then a simple re-make of the kernel ought to update that module as well, and make install and make modules_install should put it into place.

Remember that you'll have to reboot the system before attempting to install the new module.

the_unforgiven 06-25-2006 08:56 AM

Quote:

Originally Posted by sundialsvcs
Kernel modules should be rebuilt by using make in the /usr/src/linux directory. I don't see any value in trying to compile them "by hand."

Each kernel module contains a version-identifier designed specifically to prevent them from being loaded by a kernel other than the one they were built for. (Obviously, this would mean instant death. :jawa: )

This wasn't applicable in the days of 2.4.x kernels.
This is what the new kernel build system for 2.6.x kernels (kbuild) has brought with it.
For 2.4 series kernels, you have to build the modules by hand - unless they've updated the current 2.4 tree to use the kbuild process - I've not tried it in ages now. ;)

the_unforgiven 06-25-2006 08:58 AM

Quote:

Originally Posted by m.anju
hi,
I m new to linux i am trying kernel programming while insertion of mod error comes when i tried the command

#gcc -c hello.c -o hello.o -isystem /usr/src/linux-2.4.20-8/include -D__KERNEL__ -DLINUX

error: couldn't find the kernel version the module was compiled for

then instead of -isystem i tried -I the problem is not yet solved

Thanx

What's the output of uname -r command?
Are you sure you're building the module for a 2.4.x kernel?
And do you have the configured sources for your current kernel installed?

m.anju 06-26-2006 01:43 AM

# uname -r
2.4.20-8

First i installed the current kernel module then only i tried for kernel programming. Still in same problem.


All times are GMT -5. The time now is 02:01 PM.