I found that LINUX_VERSION_CODE defined in /usr/include/linux/version.h on my Ubuntu 16.04.3 LTS machine is (equivalent to) 4.4.90, whereas it is expected to be 4.10.0.

bash% lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.3 LTS
Release:    16.04
Codename:   xenial

bash% bash% uname -r

bash% cat /usr/include/linux/version.h 
#define LINUX_VERSION_CODE 263258
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))

bash% perl
my $version=263258;
my $a=($version >> 16) & 0xff;
my $b=($version >> 8) & 0xff;
my $c=$version & 0xff;
print "$version -> $a.$b.$c\n";
263258 -> 4.4.90

Therefore, a preprocessor macro as following doesn't work.

#include <linux/version.h>
// do something

Does it mean that I have some installation problem? Or are we recommended not to use LINUX_VERSION_CODE on Ubuntu?


It looks like you have a version specific kernel headers file installed that doesn't match your running kernel, probably. There used to be a meta-package that would keep the current one installed no matter what.

Here's the reference

  • Hi RobotHumans, Thanks for help. The linux-headers and linux-headers-generic are installed as following, and the proper kernel headers can be found under /usr/src on my system. Are those packages expected to update headers /usr/include/linux/version.h as well? If so, my installation was somehow wrong. Or is the LINUX_VERSION_CODE in /usr/include/linux/version.h expected to be older than uname -r version? – Ryujiro Shibuya Dec 6 '17 at 1:19
  • Might be a bug. The meta-package should mean that /usr/include/linux/version.h should reflect the latest mainline kernel version installed on your PC. Using PPAs will probably break it, but that's not a bug. That's you making it not work. So, if you installed a kernel edgers PPA, I would not expect the metapackage to reflect that data, but uname would. – RobotHumans Dec 6 '17 at 1:37
  • Thanks. Let me check if any relevant PPA is installed on the system. – Ryujiro Shibuya Dec 6 '17 at 2:30
  • I thought the dpkg installation of "linux-headers-4.10.0-28" and "linux-headers-4.10.0-28-generic" would be the kernel meta packages, but am I wrong? apt-get install linux-generic linux-headers-generic would attempt to install yet different version of packages (4.4.0-101). – Ryujiro Shibuya Dec 6 '17 at 8:15
  • Those are version specific packages. So, yeah, you broke it. If you want to install them per version, you have to change the link in /usr/src/linux to point to the right kernel version. Hence, people using the linux-headers or linux-src metapackages. They, at least on ubuntu although they never did on backtrack, update that link for you to the latest installed kernel. – RobotHumans Dec 6 '17 at 11:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.