I've recently noticed that some of the userapi linux kernel headers are declared under the GPL. However, I'm pretty sure that you can include linux uapi headers in your code without your project inheriting the GPL.

See for example https://github.com/torvalds/linux/blob/master/include/uapi/linux/input-event-codes.h.

Is it OK for a project to have #include for GPL headers without becoming GPL ? The header in question doesn't contain any "code" so to say, only defines, typedefs and structs. So there is no actual bytecode associated with this header that would be shipped in the final project.

2 Answers 2


Under normal circumstances, using a header file from a GPL-licensed project in your own project means that your code is considered to be a "derived work" of the GPL-licensed code and that you must use a GPL-compatible license when distributing your project, because the two projects are not communicating "at arm's length".

However, in the case of the Linux kernel, the COPYING file with the license contains an important addition:

NOTE! This copyright does not cover user programs that use kernel services by normal system calls - this is merely considered normal use of the kernel, and does not fall under the heading of "derived work".

This makes it clear that, as an exception to the normal GPL rules, using kernel facilities in a user application is not intended to make the terms of the GPL extend to that application. This means that applications written to work on Linux can still be closed-source.


That a header only contains "defines, typedefs and structs" is not important, the content of the file is covered by the terms of the GPL license. Headers are a part of the source code and can contain compilable code, such as inline functions, full C++ class/template definitions, a define can also be composed of defines from other headers which may add code and can be easily overlooked.

I think the distinction here is that reading an installed header file during compilation is not the same as copying the header into your project. If you copied the header file into your project you would then still have to adhere to the GPL terms.

As noted by Bart "accessing Linux kernel system calls" is not considered a derivative work. This is specific to the Linux kernel, other projects may not have this exemption, which is why the LGPL was created which specifically adds that "an Application may incorporate material from a header file that is part of the Library" so that headers may be used without enforcing the GPL terms onto the end project.

  • The distinction you make sounds like the crucial factor is whether the compiler reads the header file from the project directory or from the library search path, all else equal. That sounds nonsensical to me (the contents of the file is used in the same way), but maybe I am misunderstanding something? Jan 26, 2018 at 6:15
  • You can read the kernel headers as they are installed in the system and the license explicitly allows that, but if you copy the headers into your project then you are incorporating GPL code into your project, the same as if you took a file out of ffmpeg and saved it into your repo. What a user has installed on their system is different than code that is in your source tree. That part isn't about reading the file or combing the resulting compiled code, it is where the copy of the file is stored, on a users system or as part of your source code.
    – sambler
    Jan 26, 2018 at 6:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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