What happens if I take a small piece of code (~400 lines) that is licensed under GPLv2, and modify and use it in my own project? Am I now obliged to license my program under GPL, or can I use a more permissive license like WTFPL, or do I have to license that particular file that has the GPL-ed code in GPL, and all other files in other license?

1 Answer 1


You are only allowed to use the code and distribute it and its derivatives under the GPL unless you have permission of all authors to re-license it. That is true for a part of the code, too: deleting one half does not make the remaining half magically something not derived from the whole. A license applies to each line of code unless it says otherwise explicitly.

Thus if you want to take part of a GPL-licensed project to incorporate it into your own, you become bound by the GPL as a whole, if you compile it into one binary or they work together closer than "at arm's length" (that is closer than two separate programmes talking to eachother over a well-defined public API).

  • By "the code" you mean the one file or my whole project?
    – MetroWind
    Commented Jun 30, 2020 at 0:44
  • 1
    I amended a last paragraph to answer it also in that respect. Commented Jun 30, 2020 at 8:35
  • Thanks you for the explanation!
    – MetroWind
    Commented Jul 1, 2020 at 22:12
  • Well defined API is not enough. If the GPLed code is modified to depend on the other part, then there is one part. (the separation did not happen). Commented Jul 4, 2020 at 9:22

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.