5

I have no experience with licensing. I used GitHub to put a license in one of my repositories, which basically uses C. As I didn't want to impose restrictions (the code is a very small utility, I don't even care if someone wants to copy my code), I chose the one that was listed as 'most permissive' - MIT.

Now, I wanted to distribute my code as binaries as well. The code uses no external libraries except for the linux glibc (libc.so.6). So, I used the option -static while compiling with gcc, so that the binaries do not complain on not finding proper versions of glibc. Now, I read somewhere that I will now have to use GPL license (or the one glibc uses). I can do this, but I don't really want to because I am a hobbyist programmer and hence want to keep it as permissive as I can; the program itself is very small.

So, my questions are-

  1. Which license will I have to include after using static linking (LGPL-2.1, I suppose)?
  2. Can the source code be licensed under MIT and binaries under the license used by glibc?
  3. If the answer to (2) is yes, then is there any program that automates the process?

EDIT: I found this in one of the headers (which seems to be seem in all; this one is from math.h):-

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library; if not, see
   <https://www.gnu.org/licenses/>.

The same I find at Copying (The GNU C Library). So, it turns out that glibc uses LGPL-2.1.

7
  • Don't guess the license, look at your install. It has the license info. What is the license of the library you link? Read it and see what it has to say on the matter. Commented Jan 7, 2023 at 21:56
  • The library I link to is glibc (the standard C library). According to Wikipedia (the link takes you to the same information in glibc Wiki page), it uses LGPL-2.1 or later. How can I confirm this? Preprocessing my source code files and then grepping all text with keyword 'License'? Commented Jan 8, 2023 at 5:14
  • 1
    In order to compile and link the library, you will have to have it installed - and whereever it is installed, you will likely have also the corresponding license information. Commented Jan 8, 2023 at 8:33
  • @planetmaker, Sorry for late response. I have just edited my question adding information about the same. Commented Jan 9, 2023 at 10:51
  • Is there a reason you want to statically link to libc.so.6? Is that's the only dependency, then your binary is basically already going to work on all Linux distributions with nothing else installed.
    – Brandin
    Commented Jan 17, 2023 at 14:44

1 Answer 1

4

The LGPL permits what you describe, but there are some formalities which you must observe. Specifically, from section 6:

As an exception to the Sections above, you may also combine or link a “work that uses the Library” with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer’s own use and reverse engineering for debugging such modifications.

You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things:

a. Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable “work that uses the Library”, as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.)
b. Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user’s computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c. Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution.
d. If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place.
e. Verify that the user has already received a copy of these materials or that you have already sent this user a copy.

For an executable, the required form of the “work that uses the Library” must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.

In short, if you want to distribute binaries that use the library:

  • Your binaries must be under a license that "permit[s] modification of the work for the customer’s own use and reverse engineering for debugging such modifications." The MIT license meets this requirement, so you already intend to do this anyway.
  • You must provide a copy of the LGPL and notify users that you use a library licensed under it. This does not cause the LGPL to apply to your binary; it is an informational requirement only.
  • You must provide object or source files so that an end user could re-link against a different version of glibc (or a different libc altogether). This is not (normally) required if your binary is dynamically linked.
  • You also need to supply scripts or other materials that are required for compilation and/or linking, but you don't have to package things like the OS, the compiler, etc., unless those things are actually part of your software.
3
  • Sorry, but I changed to using musl instead and nearly forgot about this question (sorry, once again). I think there should still be an answer to this question, as it has already been asked and can help someone else. So, thank you for the answer! Commented Jan 18, 2023 at 12:03
  • My distribution system already complies with (1), (3), (4). Source and recipe to build source is provided, but in a different ZIP package than already built (ZIP) package for each release, though that doesn't seem to be a problem, does it? I also wanted to know where can we put the notice for (2) in? A file named NOTICE.md (or something else), or should be included in the LICENSE.md? Thank you once again for the answer. Commented Jan 18, 2023 at 12:07
  • 1
    @L_R: The license does not specify how or where you need to provide a copy, just that you need to do so. You can organize your repository in whatever way you think is clearest.
    – Kevin
    Commented Jan 18, 2023 at 15:53

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.