6

I'm trying to fix an old program, Previous issues I had could be found at Missing modversions.h

When I make the program it gives me the following error,

kaodv-mod.c:22:27: fatal error: linux/version.h: No such file or directory
compilation terminated.

So I ran

find / -name version.h

which returns

/opt/VBoxGuestAdditions-4.3.2/src/vboxguest-4.3.2/vboxguest/include/VBox/version.h
/usr/include/linux/dvb/version.h
/usr/include/linux/version.h
/usr/src/linux-headers-3.8.0-29-generic/include/config/arch/want/ipc/parse/version.h
/usr/src/linux-headers-3.8.0-29-generic/include/generated/uapi/linux/version.h
/usr/src/linux-headers-3.8.0-29/include/uapi/linux/dvb/version.h
/usr/src/linux-headers-3.8.0-29/include/xen/interface/version.h

This clearly proved that linux/version.h is present

In order to fix this, should I change

#include<linux/version.h>

into

#include</usr/include/linux/version.h>

Or is it possible to make changes to the Makefile

P.S: Makefile

3 Answers3

11

First you need to install kernel-headers

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

If it doesn't work then try this also

sudo ln -s /usr/src/linux-headers-$(uname -r)/include/generated/uapi/linux/version.h /usr/src/linux-headers-$(uname -r)/include/linux/version.h

Edited for types.h:

sudo ln -s /usr/src/linux-headers-$(uname -r)/include/uapi/asm-generic/types.h /lib/modules/$(uname -r)/build/include/uapi/linux/types.h
muru
  • 207,228
shantanu
  • 8,835
1

There is no include/generated/uapi/linux/version.h in source code tree starting from linux kernel 4.14;

Here is a way how to generate it under Ubuntu

  1. Install linux headers

    sudo apt install linux-headers-`uname -r`
    
  2. Go to linux headers directory

    cd /usr/src/linux-headers-`uname -r`
    
  3. Generate version.h

    sudo make include/generated/uapi/linux/version.h
    
  4. Create symbol link to generate file

    sudo ln -s $PWD/include/generated/uapi/linux/version.h include/version.h
    
1

With apt-file you can find any file Ubuntu provides:

$ apt-file search linux/version.h
gcc-arm-linux-androideabi: /usr/arm-linux-androideabi/include/linux/version.h
linux-headers-3.11.0-11-lowlatency: /usr/src/linux-headers-3.11.0-11-lowlatency/include/generated/uapi/linux/version.h
linux-headers-3.11.0-12-generic: /usr/src/linux-headers-3.11.0-12-generic/include/generated/uapi/linux/version.h
linux-headers-3.4.0-1-goldfish: /usr/src/linux-headers-3.4.0-1-goldfish/include/linux/version.h
linux-libc-dev: /usr/include/linux/version.h
linux-libc-dev-arm64-cross: /usr/aarch64-linux-gnu/include/linux/version.h
linux-libc-dev-armel-cross: /usr/arm-linux-gnueabi/include/linux/version.h
linux-libc-dev-armhf-cross: /usr/arm-linux-gnueabihf/include/linux/version.h
linux-libc-dev-powerpc-cross: /usr/powerpc-linux-gnu/include/linux/version.h
ruby1.8-dev: /usr/lib/ruby/1.8/i686-linux/version.h

From this list, linux-libc-dev looks like the most promising candidate.