Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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 '12 at 17:26
@MichaelT Wouldn't using docs and reverse-engineering protocols be a "derivative work" as well? – Anton Gogolev Jun 5 '12 at 8:57
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 '12 at 13:20
INAL, but AFAIK only automatic code translation is covered by copyright. – vartec Oct 8 '12 at 9:36
@vartec Any proofs for that? – Anton Gogolev Oct 8 '12 at 9:46
up vote 11 down vote accepted

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.

share|improve this answer
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. – Onorio Catenacci Jun 4 '12 at 17:01
@Onorio: GPL isn't a copyright, it's a license. – Mason Wheeler Jun 4 '12 at 17:08
@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. – GlenH7 Jun 4 '12 at 17:48
@MasonWheeler "means either the Program or any derivative work under copyright law"--again, not a lawyer but that does seem to say that copyright would be involved somehow. – Onorio Catenacci Jun 4 '12 at 19:33
@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 '12 at 13: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.

share|improve this answer
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 '12 at 12:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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