Linux/Module.H No Such File or Directory

linux/module.h No such file or Directory

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.

Error compiling kernel module linux/module.h: No such file or directory found

Ok I figured it out, and now I feel so silly...

I was running $ make but I was getting an error

make: Nothing to be done for `all'.

I took this to mean that I wasn't calling make properly so I started calling $ make hello to "attempt to make the module" This is where the confusion began as trying to make the file like this was not running the correct make file on my system.

Instead, the real solution was to edit the Makefile to take out the spaces before the build calls and replace them with tabs. This completely fixed my issue and I was able to build without a hitch.

error compiling: linux/module.h: No such file or directory

First thing you need the kernel sources. Many confuse user space headers and kernel space headers because many of them have the same folder structure. Most of the distros only have the user space headers and not the kernel space ones.

And generally make is used to build a kernel module and not a bare cc. Follow the simple step-by-step explained Hello World kernel module given here

linux/kernel.h : No such file or directory

Do you have /usr/src/linux symbolic link to your /usr/src/linux-headers-2.6.35-28-generic ?
If not then create one using following commands

# cd /usr/src
# ln -sfn linux-headers-2.6.35-28-generic linux


Related Topics



Leave a reply



Submit