I want to use one source code file from other open source project which is licensed under GPL3. That source code will be used to perform a single task in my project.

My entire project is licensed under MIT license.

Can someone please suggest, how can I do that without violating LICENSE term of other project? How and where to include other project's license in my project?

2 Answers 2


As per GPL, if you use GPL code in your project, the whole shebang must be under GPL. If that isn't acceptable, you'll have to find a way around that (find another one with a MIT-compatile license, write your own MIT-licensed version, don't use that functionality, ...).

Be careful, looking at the GPLed code while writing your own can/will be construed as copying. You'll have to make sure it is as different as possible from the original: Use a different algorithm, place different constraints (e.g., narrowly designed for your use, not generality; efficiency vs code clarity; ...). Take a peek at the advise the FSF gives (gave? it has been quite some time) while creating clones of Unix utilities, to make sure the result can't be sued as an illegal copy.

  • The GPL is considered viral for a reason and this is it. Bringing a single file into your project causes the whole thing to become GPL. There's a reason businesses avoid GPL like the plague. Aug 27, 2020 at 3:42
  • 1
    @wswartzendruber I'm sorry to disagree, but that's utter FUD. I run a business, and not only do I not avoid the GPL, I embrace it: our work for clients is given to them under GPL, and once they understand the win, they are fine with it. I'm sorry if you've only run into businesses who don't like copyleft, but many are not like that.
    – MadHatter
    Aug 28, 2020 at 19:54

This is not legal advice.

The GPL is a complicated license. Part of the problem here is that it uses the words "based on" to determine whether your code needs to go out under the same license. If you're thinking "my code isn't based on this one file," hold on.

"Based on" echos the statutory definition of a "Derivative Work." The jurisprudence around derivative works in software is still very hazy, as not that many cases have gone to trial on this issue. However, the tests the FSF and others have put together involve a few simple guidelines.

  • Your code can't link statically or dynamically to the GPL code. In interpreted languages, runtime imports are still a lot like dynamic links, and probably aren't good ideas.
  • Your code can't be combined in with the GPL code in a way that they can't be separated easily. Webpack is a good example of this. You also can't just mix functions into the same file by copying and pasting or something dumb like that.
  • "Mere aggregation" is allowed -- they are allowed to sit in the same directory or go out on the same hard drive or the same zip folder or something like that.
  • Something like a command line call is probably safe, as long as you're interacting with it in some standard, natural way. Don't try to smash your way in through the back door when there's a front door.

The GPL-licensed code still needs to go out under the GPL, but your project itself could go out under the MIT license.

If that's still not super clear to you... You could hire your own attorney. If it's worth it. Note that I am not your attorney, and nothing in this comment comes close to establishing an attorney-client relationship.

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.