I have a software that I'm sharing under MIT license. I would like to add some GPL library to accelerate some algorithms. I #ifdef the includes and calls to this library so that my application can be compiled without the GPL code. The include statements to this third party library and references to it in the makefile are still there though. Can I keep the MIT license on my software project or do I need to change it to GPL? How do I need to structure the license of my git repository in this case?


You can license your source code under MIT, since your source code doesn't contain GPL-covered parts.

However, when you compile the software with the GPL component, then the binary as a whole can only be licensed under the GPL with all the obligations that implies, like providing the complete corresponding source code of the binary – including your MIT-licensed parts. There is no fundamental difference between an MIT project including GPL code vs a GPL project including MIT code.

  • Thanks! I currently use the default github generated MIT license - so there is simply a LICENSE file in the root of the repository with the MIT. Do I need to specially mention in it that the software won't fall under MIT depending on how it is compiled? – matthias_buehlmann Aug 11 '20 at 9:51
  • 7
    @user1282931 It would be helpful – but is not required – to inform users about this. Perhaps your build instructions are a good place, perhaps a license information paragraph at the end of the readme. For example: “All the code in this project is available under the MIT license. If you compile with `-DSOME_FEATURE, the GPLv3-covered libfoo will be linked.” – amon Aug 11 '20 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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