I want to really opensource a project that did start as a personal hobby, but I'm an ignorant of licensing details.

This project, provides some libraries for a given $language, and some wrapper command line utilities for those libraries.

Those libraries, across many things, do generate more code in the same language, code which can be reused by the caller.

On my drafts, I always used a MIT style license for the sake of brevity, but it's unreleased copies I'm reviewing right now to merge on a finally released version.

I would like to use GPL style policies for usage/contribution of my code (lets call it a framework).


Could choosing GPLv2 (3?) for my project, limit the things that a given user can do with the code generated or managed by my libraries/utilities? (i.e. commercial profit of such generated code without release her improvements/changes to my code)

Is there something to consider (in a plain language) when licensing code that generates code ?


To try to answer some comments:

  1. What do you wish to accomplish with your license?
    The best goals for the project health (from the view point of a community-based opensource project).

  2. Who do you want to use your code?

  3. What do you want to happen to changes?
    To be back-ported to the project as much as possible.

  4. What do you want to happen to generated code?
    To don't be affected by my licensing choice. It belongs to the user who generated it.

  5. What about money - if the user makes money do you want that to affect the licensing?
    If the user makes money from the generated code, great. If the user makes money modifying my code, I would like to force to publish the changes.

I did a group-therapy with those answers. Now, choosing GPL (2? 3?) I could be ok or not?


So they have to bundle/compile your library in with theirs when they deploy it, in order for it to run?

yes, the library needs to be installed previously, or bundled with the result (there is an option for this).

  • What do you wish to accomplish with your license? Once you've worked that you, then you can choose a license. Who do you want to use your code? What do you want to happen to changes? What do you want to happen to generated code? What about money - if the user makes money do you want that to affect the licensing? Once you have those answers, you can pick (or write) a license that fits your desires. Commented Dec 16, 2013 at 22:06
  • Will the end user's project be able to compile without your code-generating-code? Specifically, is it a tool which they can say "Generate a default class with these fields", get an appropriate code file in their language, and then never refer back to your code? Or is it more like they interleave special things into their code which your code expands on?
    – Bobson
    Commented Dec 16, 2013 at 22:09
  • Michael kohne, as reading, I was thinking... "how many questions" but the colophon did put me to think... I still don't have the answer for some of them. Thanks.
    – user111922
    Commented Dec 16, 2013 at 22:16
  • Bobson, there is a "core" library. Without that library, any other part of the generated code works, unless the user provides her own implementation of the "core" functions.
    – user111922
    Commented Dec 16, 2013 at 22:17
  • So they have to bundle/compile your library in with theirs when they deploy it, in order for it to run?
    – Bobson
    Commented Dec 16, 2013 at 22:22

2 Answers 2


The main thing to consider when choosing the license for a code generator is how much of the code generator itself will wind up in its output. With most (all?) compilers, this is such a small portion that the compiler's license is not considered to apply to the compiler's output. This makes it possible to use GPL-licensed compilers to write closed-source software, because the end-product is not considered to be derived from the compiler's source.

On the other hand, there are also tools like Bison, where a significant portion of the tool makes it into the output. As Bison is licensed with the GPL, this would normally mean that and software you generate with Bison would also be covered by the GPL, were it not that the Bison license has a special clause to allow its output to be used in (a limited set of) closed source projects.

As you do not wish to restrict the uses of the generated code, but you do want modifications to the generator and libraries to be made public, your best choice seems to to use LGPL or a permissive license for the libraries (provided they can be linked dynamically to the user's project) and GPL (optionally with a Bison-like exception) or a permissive license for the code generator.

  • Very useful information. I don't know what license I will go with finally (maybe even I keep the MIT style one to avoid those caveats to potential users). But your comment was very useful, so accepted. Thanks.
    – user111922
    Commented Dec 17, 2013 at 18:46

Disclaimer - IANAL and the following is not a legal advice. The exact detail may vary depending on your jurisdiction as well.

The interpretation of FSF, which tend to be the strictes, is that the generated code is not covered by license. So you can use gcc to compile a commercial project and distribute the binary. Similarly using a GPL implementation of System API is allowed. However the linking with library is prohibited. I know that not every layer agree with latter interpretation but I don't know the details (the main point is what's a 'derived project') - if you want to know the details you might want to consult a layer. In such case bundling library would move toward 'derived project' (again IANAL).

If you don't want to limit in such way the general practice is use LGPL, GPL with linking exception or any other copyleft license. The latter is more liberal as the former require the third party to be able to relink with different version of library (again - if the clauses are enforceable is debated). In general I'd advice to stick to well know licenses such as (L)GPL, MIT/BSD3, Apache 2.0 etc.

However license is just giving permission. If you publish code on GPL you can republish it under different license as long as you are the copyright holder or have a license to do so (so, for example, if you take the contribution from third party you need to ask for permission). You can even sell a license to some company as was a monetization model of some FLOSS projects.

Final remainder - I am not a layer and this was not a legal advice.

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.