I have a very vague impression regarding the GPLv2 license that any project which borrows code from a GPL project needs to be open source too. Now I have a situation that I read part of a GPL project's code and there are around four functions that I would like to borrow for our commercial project.

I converted it into another language and also removed/modify some code in order to fit our project.

Is it illegal?

  • 7
    It might be interesting to note that software companies go through great pains to accomplish what you just wrote legally. The classical example of this is en.wikipedia.org/wiki/Clean_room_design
    – ldog
    Mar 18, 2022 at 21:43
  • I'll not answer wrt the legality, but one question "for a few lines of code; slightly modified" that one always has to ask oneself in practice is whether there is ever any chance that the (possible) copyright violation can be even detected down the line.
    – Martin Ba
    Mar 19, 2022 at 21:14
  • That should depend on how much "conversion" is involved. I guess "… into another language" means into another coding language and I suggest that might give you some kind of joint rights, but never absolve you of a duty to follow the original developer's wishes. Removing code to fit your project should make no difference. Modify code for whatever purpose, always depends on how far the code is modified Mar 20, 2022 at 17:41
  • I'm putting this in a comment because I can't remember exactly whether this is correct for GPLv2, but you could create an open-source library that contains those four functions, link to the library from your proprietary software, and make available the source code for the library. Mar 20, 2022 at 21:52
  • 1
    @NonnyMoose it is not correct. You might be thinking of LGPL. And why people should not make their software LGPL. Mar 21, 2022 at 9:45

5 Answers 5


tl;dr: maybe illegal, trending towards probably illegal. Almost certainly too high a risk for a sensible company to take on.

First things first: open sources licenses allow for commercial use so you can absolutely do this if you are prepared to abide by the GPL for your project. I suspect you are making the common error of using the term "commercial software" when in fact you mean "proprietary software". The rest of this answer assumes you mean proprietary software.

The question is as always "is your code a derivative work of the GPL code?" That is something which is a question of copyright law and will actually vary according to the jurisdiction in which any potential legal action occurs, but as a very rough rule of thumb:

  • If you did a "mechanical" translation from one language to another, similar to taking each line of code and changing it into the same line of code in another language, then your work is almost certainly a derivative work and you must abide by the GPL.
  • If you did a more "hands off" translation, for example just taking the API definitions from the GPL code and making the implementation from scratch in your code, it might not be a derivative work.

However, at this stage it's going to be incredibly hard for you to prove that you weren't influenced (even unintentionally) by having seen the GPL code so I would not be prepared to take the risk. Just find a non-GPL source of the functionality you need and use that instead.

  • 7
    Alternative for the final suggestion would be to ensure that someone else (who hasn't read the same sources) implement the required functionality. I.e. arrange a clean room implementation. Mar 19, 2022 at 8:44
  • 3
    On the other hand, it may also be pretty hard to prove that the code was influenced by the GPL code so much that it is derivative. AFAIK the burden of proof is on the plaintiff.
    – jpa
    Mar 19, 2022 at 8:49
  • 7
    @jpa In UK law, this would be a civil case and therefore on "balance of probabilities" with no burden of proof on either side. See for example the currently ongoing case involving Ed Sheeran which while about music rather than code is essentially the same thing. Mar 19, 2022 at 8:54
  • Regarding commercial/proprietary software perhaps the biggest question is whether the product is distributed. If the software is just run on a server there might be no breach at all even if a huge amount of code is copied.
    – md2perpe
    Mar 20, 2022 at 20:57
  • In the US, Google vs Oracle established a precendent for fair use of APIs outside of copyright restrictions, so I would assume that your second example doesn’t constitute a derivative work (or at least isn’t bound by the orginal licence). Mar 21, 2022 at 7:42

Adding to the accepted answer, I'd like to point that the answer to your question highly depends on the nature of the function too.

Take a recursive factorial in Java:

public static long fact(long n) {
  if (n <= 1)
     return 1;
     return n * fact(n - 1);

Even if you stole this from a GPLv2 project, it's going to be hard for the original author to argue that you did.

IANAL but with any copyright claim comes the question of how "original" the work is. Have you copied functions that are pretty clever and bring a unique solution to a problem? Is the problem solved itself very unusual...? Or is it like my factorial example above?

  • 2
    Re "it's going to be hard for the original author to argue that you did.", That's not the legal standard, at least not in the US. For an exact copy, one doesn't need to prove they actually copied it. One simply needs to prove access to the original. (There are defenses here, and the size will help. There are only so many ways to implement this algorithm...)
    – ikegami
    Mar 21, 2022 at 17:44

Though this question has already been answered, one point has not been addressed. Is your project for external distribution? If not, it's a moot point since distributing the application internally is not "distribution" so it doesn't confer GPL obligations. (Exception: the Affero GPL is a use license rather than a pure distribution license; it considers interaction with servers to be like distribution, so it may confer additional obligations if the project serves clients outside the company.)

  • I'd wonder: is giving a coworker a copy of the program a distribution? If it is, coworkers could just leave the company with a copy of the software source code... Mar 20, 2022 at 7:53
  • @user1532080 We have a very good question on that already, although the answer is in the GPL FAQ. Mar 20, 2022 at 8:26
  • "distributing a part of the application [i]nternally with the GPL license and source is not a big burden" There is no need at all to distribute the source if the use is purely internal. Mar 20, 2022 at 8:26

What's best for everyone involved, including yourself, your career, and the company employing you:

Read the source code. Find out how the source code works. When you know how it works, write it yourself. Without seeing the original source code. That way you are not copying anything, so you are not committing copyright infringement.

If you just take some GPL licensed code and add it to your project, then you have the choice: You license your project under the GPL license, or you admit that you committed copyright infringement and can be sued. If the copyright holder of the GPL licensed source code finds out (how could that happen? Well, maybe your colleague calls them and tells them), not only is your company in trouble, but your career is in big trouble. So you will never do this without talking to your company's lawyer (unless it is common knowledge in your company that the whole product is GPL licensed).

But even if the product is GPL licensed: Many companies use "dual licensing". I can download their source code for free under the GPL license, or I can get a license with full product software for lots of money. If the company does that, they can't just use someone else's GPL licensed code, because then they are not allowed to do dual licensing anymore which kills the business.

So: Don't do it unless you talk to your lawyers. And very often lawyers are expensive, so your boss will tell you not to do it, because it's cheaper you write it yourself, than copying and getting your lawyers involved.


One of the stated main intentions of GPL is to force applying it to every project that makes any use of any GPL code. I don't know "the letter of the law", but since forcing you was precisely what was intended and you're asking "Am I forced to?", the answer is "Yes, you're forced to."

  • 1
    The question is really what counts as "makes any use of". There are most definitely things which some people would think of "making use of" which the GPL does not cover. Mar 19, 2022 at 20:50
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Mar 20, 2022 at 9:13

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.