2

I'm trying to understand how OS licensing works for C applications. I developed an application which makes use of the following header files:

  • errno.h
  • getopt.h
  • inttypes.h
  • signal.h
  • stdbool.h
  • stddef.h
  • stdio.h
  • stdlib.h
  • string.h
  • unistd.h
  • sys/mman.h
  • sys/resource.h

For testing I use also:

  • assert.h

From what I can see these header files on macOS use one of the following licences:

  • Apple Public Source License Version 2.0
  • Apache-2.0 WITH LLVM-exception
  • BSD-4-Clause (getopt and assert.h only)

The same header files on Ubuntu Linux 22.04 use a different set of licences:

  • LGPL 2.1+
  • GPL 3+ with GCC Runtime Library Exception

At this moment I do not intend to release binaries or Docker images, only source code together with CMakeLists.txt and Dockerfile. I intend to use MIT license, if possible.

  1. Am I right thinking that as long as I don't release binaries, can I use MIT license?
  2. If my reasoning in question 1 is incorrect, how am I supposed to figure out suitable license, given that I won't know what license these libraries will use on the machine where someone might compile the source code?
  3. What is the standard practice for licensing multi-platform applications implemented in C, if binaries are built and distributed, and the licenses vary between operating systems?
  4. In case of releasing binaries, does dynamic vs static linking matter at all?
New contributor
user1069483 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
4
  • Which header file on Ubuntu claims a GPL 3+ license? See also: opensource.stackexchange.com/questions/9833/…
    – Brandin
    2 days ago
  • stdbool.h and stddef.h 2 days ago
  • @user1069483: Are you absolutely sure it is under a straight GPL license, and does not have a notice like this one on it? It is very surprising to hear that C standard headers are under a copyleft license.
    – Kevin
    19 hours ago
  • You are correct, these are GPL with GCC Runtime Library Exception. I've updated the question with this important detail. 15 hours ago

1 Answer 1

2

There are a few different parts to this:

  • For source distributions, you are (probably) not going to distribute those header files along with your application, so you only need to comply with their licenses if your source code is a derivative work of the headers. But the headers you have identified are (with one exception) standard headers that provide APIs as specified by ISO C and POSIX. Even if those APIs are subject to copyright protection (which is doubtful in many countries), they are not the property of whoever implemented the header - they are the property of ISO C and POSIX, neither of which have ever claimed to own any of their standardized APIs. Therefore, for a typical source distribution, you can use whatever license you please... except for getopt.h, which as far as I can tell is a nonstandard Gnulib header. Because Gnulib is not a standard library, your source code might reasonably be a derivative work of Gnulib. You should consult the license header of this file to determine what license it is under. If it is under the GPL, you may need to put your source code under the GPL. Alternatively, switch to using the POSIX getopt and stop including getopt.h.
  • For binary distributions, this is more complicated. Headers can contain inline functions (and some other things as well), which go beyond merely specifying an API, and actually include real logic that is copied directly into the binary at compile time (not link time!), so the binary is certainly a derivative work of any such inline functions. Regardless of whether such functions are present in the header, the compilation process also creates linker bindings for later dynamic linking, and it has been argued that linker bindings alone make the binary a derivative work of the library as a whole. So, if any of the libraries you link to are licensed under the GPL, with no linking exception like this one, it is prudent to assume that the binary is a derivative work of the library, and must be GPL-licensed and comply with GPL formalities (i.e. you must provide source code). Having said that, you might reasonably prefer to link against a different libc instead. glibc, for example, is licensed under the LGPL, which has an explicit exception for linking, and so you are not required to apply any particular license to a binary which links against glibc, as long as you otherwise comply with the LGPL (and all other applicable licenses, for all other libraries used).

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.