linux/module.h No such file or Directory
Asked Answered
I

2

5

For my thesis I am creating a Manet using the protocol ARAN. To install the protocol I'm using this manual, but the first step, the creation of trace_route, I received errors such as:

-linux/module.h: No such file or directory

-linux/procs_Fs: No such file or directory

-linux/skbuff: No such file or directory

I searched the web and found out that the problem is in the headers, but I do not find the solution ...

P.S. I am using Ubuntu 10.04 LTS Kernel 2.6.33 recompiled

Incorporator answered 4/6, 2013 at 13:43 Comment(0)
H
10

You're missing the Linux kernel headers which allow you to compile code against the Linux kernel.

To install just the headers in Ubuntu:

$ sudo apt-get install linux-headers-$(uname -r)

To install the entire Linux kernel source in Ubuntu:

$ sudo apt-get install linux-source

Note that you should use the kernel headers that match the kernel you are running.

Hipparchus answered 4/6, 2013 at 17:32 Comment(0)
R
3
**/*source file name is basic.c */**

#include <linux/init.h>
#include <linux/module.h>
/*MODULE_LICENSE("Dual BSD/GPL");*/
static int hello_init(void)
{
    printk(KERN_ALERT "Hello, world\n");
    return 0;
}
static void hello_exit(void)
{
    printk(KERN_ALERT "Goodbye, cruel world\n");
}
module_init(hello_init);
module_exit(hello_exit);

=====================================

now make file for ubuntu

/*at first type on ur terminal that $(uname -r) then u will get the version.. that is using on ur system */

obj-m +=basic.o

KDIR =//usr/src/linux-headers-3.13.0-44-generic

all:
 $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
 rm -rf *.o *.ko *.mod.* *.symvers *.order

================================================

To run the code

$sudo insmode basic.ko
$dmesg
u will get the output
$sudo rmmod basic.ko
$dmesg
Rickey answered 4/3, 2015 at 20:10 Comment(2)
Nice working example of the example in 'Linux Device Drivers, Third Edition' - Thanks.Macaroon
Thanks sir @SimonPeverettRickey

© 2022 - 2024 — McMap. All rights reserved.