I rewrote some parts of Mercurial (which is licensed under GNU GPL v2) in C#. Naturally, I looked a lot into original Python code and some parts are direct translations from Python to C#.

Is is possible have "my code" licensed under different terms or to even make a part of a closed-source commercial application? If not, can I re-license "my-code" under LGPL, open-source it and then use this open-sourced C# library in my closed-source commercial application?

  • 4
    If you worked from the original code (rather than reimplementing from the protocols and documents) it may fall into the realm of "derivative work" in which case it may still fall under the original license. Talk to a lawyer.
    – user40980
    Jun 4, 2012 at 17:26
  • @MichaelT Wouldn't using docs and reverse-engineering protocols be a "derivative work" as well? Jun 5, 2012 at 8:57
  • 4
    not necessarily. The derivative work takes the original and transforms it into another form. With more traditional media, a painting is copyrighted, a photograph of the painting is a derivative work. When done correctly, a clean room reverse engineering avoids this. See also What are the copyright & licensing issues of porting code? from SO.
    – user40980
    Jun 5, 2012 at 13:20
  • INAL, but AFAIK only automatic code translation is covered by copyright.
    – vartec
    Oct 8, 2012 at 9:36
  • 1
    @vartec Any proofs for that? Oct 8, 2012 at 9:46

3 Answers 3


The text of the license specifically covers translations, so no, you wouldn't be able to relicense it.

The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language.

  • 3
    IANAL but I would guess "Translated into another language" in this context isn't referring to a different programming language. Copyright law only protects the exact expression of an idea--not the idea itself. Jun 4, 2012 at 17:01
  • 3
    @Onorio: GPL isn't a copyright, it's a license. Jun 4, 2012 at 17:08
  • 5
    @OnorioCatenacci this is one of those cases where "language" becomes a bit sticky. The key phrase is "derivative work", which the OP has most certainly created. GPL expressly allows for the creation of derivative work (aka, it's "Free ..."), but the original licensing restrictions still apply to the derivative. GPL allows for some re-licensing (shameless plug, see my answer). This is more a question about licensing as opposed to copyright.
    – user53019
    Jun 4, 2012 at 17:48
  • 3
    @MasonWheeler "GPL isn't a copyright, it's a license." Would you care to explain that? All a license can do is grant you certain rights to a copyrighted work. If (big if) the copyright in the new work can not be claimed by the original works copyright holders then the license doesn't apply.
    – Jaydee
    Jun 5, 2012 at 13:02
  • 1
    I downvoted this because this is not the reason it's illegal. The license can say whatever it wants, but that doesn't make it true. In particular, note that the license grants you permission to translate the program into another language, but that does not imply that you don't have permission outside of the license. Oct 27, 2020 at 19:02

Based upon:

You should be okay with the second scenario you portrayed.

The parts you copied remain under GPLv2, but your entire library can be released as LGPL v2.1 or later. You can then link your closed source code to that library under the terms of the LGPL.

As always, do some digging and make sure you understand what the restrictions are.

  • 9
    Definitely not. Think about it: The GPL would not make any sense if it was like that. You could just take any GPL v2 code, and switch it to LGPL. That would make the GPL superfluous. Take a look at the fineprint: "LGPLv2.1 gives you permission to relicense the code under any version of the GPL (not LGPL) since GPLv2. If you can switch the LGPLed code in this case to using an appropriate version of the GPL instead (as noted in the table), you can make this combination." That only means that it's legal to switch your LGPL library to GPL, but not vice-versa. Which makes sense again.
    – Quandary
    Sep 4, 2012 at 12:51

If you created a brand new work (and you are prepared to defend this in court) that isn’t derived from the GPL licensed work then you can do whatever you like. If you created a derivative work, then you need to license it under the GPL.

It depends on how much you copied (and a mechanical rewrite would count as copying). Nothing copied, no license requirements.

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