Mahi
Mahi

Reputation: 11

GCC-Kernel version Mismatch

I am trying to build a kernel module. But when I am trying to compile the code I am getting the following error.

ERROR: gcc/kernel version mismatch
+ echo 'gcc version:    4.8.4-2ubuntu1~14.04.1) 4.8.4'
gcc version:    4.8.4-2ubuntu1~14.04.1) 4.8.4
+ echo 'kernel version: 4.8.2-19ubuntu1) 4.8.2'

I am using ubuntu Ubuntu 14.04.4 LTS. Any help is appreciated

Upvotes: 0

Views: 2414

Answers (2)

Samrat Das
Samrat Das

Reputation: 1918

you can go through this answer. It will tell you why it is important to build module on exact running kernel version. Because of which gcc is not allowing you. You can use

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

After installing, edit your makefile to use current version headers, uname -r will help you out for this

obj-m += hello-1.o

all:
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

clean:
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

Upvotes: 0

Harry
Harry

Reputation: 11648

The version the of the kernel you are building against does not match the version installed. You need to build against the correct version of the kernel. Use aptitude and match up the headers with the version of the kernel you want to build against and compile with these.

Upvotes: 1

Related Questions