LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Inserting the module (https://www.linuxquestions.org/questions/linux-newbie-8/inserting-the-module-4175489141/)

Lokesh2015 12-25-2013 12:57 PM

Inserting the module
 
Hi,
I am new to kernel, And I am using 3.12.0 kernel version. I wrote my first Hello.c file and compile using 3.2.0-57-generic-pae linux header. Compilation was done nicely but when I try to execute the insmod Hello.ko "An error msg is displayed-- invalid maodule format." How could I use my newer version for compiling , inserting and to dispaly the message on the older linux. I am using linux 3.2.0. I don't want to remove the old version. Please help....

lemon09 12-26-2013 06:32 AM

please give information like how did you compile the code. What flags did you provide to compile. This post may help you.

Code:

1.2.1.3. Compiling Issues and Kernel Version

Very often, Linux distros will distribute kernel source that has been patched in various non-standard ways, which may cause trouble.

A more common problem is that some Linux distros distribute incomplete kernel headers. You'll need to compile your code using various header files from the Linux kernel. Murphy's Law states that the headers that are missing are exactly the ones that you'll need for your module work.

To avoid these two problems, I highly recommend that you download, compile and boot into a fresh, stock Linux kernel which can be downloaded from any of the Linux kernel mirror sites. See the Linux Kernel HOWTO for more details.

Ironically, this can also cause a problem. By default, gcc on your system may look for the kernel headers in their default location rather than where you installed the new copy of the kernel (usually in /usr/src/. This can be fixed by using gcc's -I switch.


You can find in the following file:
Code:

http://www.tldp.org/LDP/lkmpg/2.4/html/x49.html

Lokesh2015 12-26-2013 11:27 AM

Inserting the module
 
Actually I have installed the linux kernel 3.12.0. And now compilation is not a problem. When I am inserting module is the problem. Compilation is done succesfully when using linux-headers-3.2.0.57 but it's unable to insert. But when I am changing linux-headers-3.2.0.57 to linux-3.12 it's nicely inserted, but the problem with compilation remains.
Any help??


All times are GMT -5. The time now is 08:19 PM.