building a module
Iam getting an error while linking the following module to my kernel......
//module.c #define MODULE #include<linux/module.h> #include<linux/kernel.h> int init_module() { printk("<1> HEllo my boss\n"); return 0; } void cleanup_module() { printk("<1> good bye my boss"); } i can able to compile success fully... # gcc -c module.c but when iam trying to insert this module.... # insmod ./module.o Iam getting this erro.. your kernel is mismatched.. your kernel version is 2.4.0-20.this is compiled for 2.4.0 on linux 9.0... even i tried on linux 7.0 here also iam getting same error.. your kernel is mismatched.. your kernel version is 2.....this is compiled for 2.4.0 on linux 7.0... can any one help for this experts.. ------------- mahi |
The kernel will not load modules compiled for another kernel version.
I advise you to go to this URL, Linux Documentation Project - LKM in the first chapter it explains what needs to be done. -hope that helps, sorry I couldnt give a longer explaination. I dont have my "linux device drivers" book handy. |
Thank you mr.jinksys...
for givin this valuable information.. |
You are so very welcome.
|
Can u help me little bit brief...i gothroughed the pdf...but still iam getting the same error...
if it possible can u help me with detail.. |
|
can you post how you compile your code? Could you also email your code to jinksys444@charter.net?
|
Hai...
#define MODULE #include<linux/module.h> #include<linux/kernel.h> int init_module() { printk("<1> HEllo my boss\n"); return 0; } void cleanup_module() { printk("<1> good bye my boss"); } after finishing this code i come out of the vi editor...and.. i compiled like # gcc -c module.c #insmod ./module.o here iam getting the error like ur kernel version mismatched.. rgds, mahesh |
Thanks for posting and emailing your code.
You were compiling your module incorrectly. Before you can compile your module, you must be sure that the kernel sources you have installed are the same version as the running kernel. To remedy this, you need to do two things. 1) execute this command... Code:
cp /boot/vmlinuz.version.h /lib/modules/`uname -r`/build/include/linux/version.h information, and will override the kernel source's version macros. 2) you need to compile your modules like this... Code:
gcc -I/lib/modules/`uname -r`/build/include -c mymod.c -o mymod Execute Code:
insmod ./yourmodhere should be loaded. On my machine printk's output was printed in my logs and not on the terminal. Depending on your kernel version and your klogd configuration, your results may vary. Hope I helped. |
Mr. jinksys..
I have tried in linux 7.0 my kernel version is 2.2.16-22..here i couldn't find the file like vmlinuz.version.h in /boot directory.. u told about the kernel 2.4....or 2.2... in my workplace i have the linux 7.0 in my pc i have linux..9.0.. right now iam trying with linux 7.0... can u help me... rgds, mahesh |
You say linux 7 and linux 9, what distro are you talking about?
Redhat, suse, mandrake, etc? |
Iam talking about redhat linux 7.0 and redhat Linux 9.0.
i have follwed ur method ..but while copying cp /boot/vmlinuz.version.h /lib/modules/`uname -r`/build/include/linux/version.h it is giving error... that there is no file like vmlinuz.version.h i tried it in both redhat linux 7.0 and redhat linux 9.0... i can't able to build the module... help me on this.. |
hey i am trying to do somethign exactly similar and i am stuck on the same problem...will u plz tell me if u find out how to solve the version problem for hello world program. I am using RH9 2.4.20-8
|
Hai experts...
Could u help for this problem...... I can't able to build a module ...... |
module build
Hi,
Pls let me know whether your kernel is compiled with module version support = yes. if not do that. after this compile the module source code with following command #gcc -D__KERNEL__ -DMODULE -c -I/usr/src/linux-XX/include module.c where /usr/src/linux-XX will be your source directory path. and 'module.c' is your source file(module prog. code) then just folow with 'insmod' I hope that you will succeed this. if you have any problem let me know. Regards Mahesh |
All times are GMT -5. The time now is 09:28 AM. |