
Ask HN: Could I use GPL licensed library in my MIT licensed project? - huxingyi
I have been working on my side project for years, and I am preparing to release the 1.0 stable version. The project is on MIT license since the first day, and it’s my preferred choice. However, I introduced CGAL library to my project later, and it’s GPL licensed. Currently, there is no other choice, I have to use CGAL library.<p>1. Does that means I have to change my whole project to GPL license?
2. Suppose I license my project as GPL, in the future, if I found a replacement for CGAL, could I relicense my project back to MIT if I remove all GPL related code? Or all my code have been infected as GPL and I lose control of all of them?
3. If I allow user add and run Lua script in my GPL licensed software, does the Lua script forced to License on GPL also?
======
belorn
1\. The other parts of the project can remain MIT or any other gpl compatible
license. A condition for distributing the GPL library is that the whole
project get covered by the GPL. A way to look at this is to think of parts
only having to follow their own license, while the combined work has to follow
all licenses that has clauses for combined works. In practice this mean that
for example the GPL patent clause will cover the whole project and not only
the library.

2\. As each part has it own license you can mix and match how ever you want as
long as the combined parts are compatible. If you are the author of all the
project code (other than the CGAL library) then you have additional rights to
change the license of future version, but in this case it is unlikely to
matter as MIT is very permissive license. As the copyright author, the only
way to "lose control" is that you can't retroactive change licenses of past
publications of old version. New publications and new version however is fully
within the control of the copyright author.

3\. Plugins live in a grey area of copyright. From what I have seen the most
common answer is that they are not covered by the license of the main program.
Different organization makes different interpretation here, and for what it is
worth FSF has published where they will enforce GPL
([https://www.gnu.org/licenses/gpl-
faq.html#GPLPlugins](https://www.gnu.org/licenses/gpl-faq.html#GPLPlugins)). I
think Linux foundation determine the line based on GPL_ONLY flag in the kernel
code, and wordpress has it own interpretation. I would however say that it is
a bit of a stretch for a library authors to complain about the plugins
licenses to software which uses the library unless there is very heavy and
obvious 1:1 link between the plugin API and the library.

~~~
huxingyi
Thanks, to conclude from your detailed answer: I can still license the code
other than CGAL to MIT, but license the whole project to GPL, and in the
future if I removed CGAL, I can license the whole project back to MIT. And the
plugin API is not related with CGAL at all, so I can let the user choose
whatever the license.

------
laken
1\. MIT can easily be re-licensed as GPL. You can keep a branch of it right
before the introduction of CGAL, so if someone really wanted to, they could
replace it with something else themselves.

2\. This is where it gets tricky. Yes, though you'll need the permission of
all your contributors to the GPL version of your project, and replace all the
GPL code ith similar functioning code. You should avoid just line-by-line
rewriting of the GPL code though, you'll need to have a unique implementation.

3\. Again, tricky, but MIT would probably be OK, because MIT is compatible
with GPL, if it's within the GPL'd project.

~~~
huxingyi
Thanks, > 1\. MIT can easily be re-licensed as GPL. You can keep a branch of
it right before the introduction of CGAL, so if someone really wanted to, they
could replace it with something else themselves.

It's too late, I introduced CGAL very early.

> 2\. This is where it gets tricky. Yes, though you'll need the permission of
> all your contributors to the GPL version of your project, and replace all
> the GPL code ith similar functioning code. You should avoid just line-by-
> line rewriting of the GPL code though, you'll need to have a unique
> implementation.

So, I guess it's a Yes. If I removed CGAL in the future.

> 3\. Again, tricky, but MIT would probably be OK, because MIT is compatible
> with GPL, if it's within the GPL'd project.

Basically, if I have to license my project on GPL because of CGAL, I would
like the scripts wrote by user could license on whatever user like. But I am
not sure if is possible.

~~~
laken
> Basically, if I have to license my project on GPL because of CGAL, I would
> like the scripts wrote by user could license on whatever user like. But I am
> not sure if is possible.

It'd have to be a "compatible" license to be allowed. Here are the compatible
licenses: [https://www.gnu.org/licenses/license-
list.en.html#GPLCompati...](https://www.gnu.org/licenses/license-
list.en.html#GPLCompatibleLicenses)

~~~
huxingyi
Thanks, so that means the user have to open source their script also.

~~~
laken
Kinda. If it's strictly for personal use and not shared, there's no
obligation. If the user is distributing the script in any way, they would be
obligated to "share" the changes to the world by having it be free software as
well, yes.

------
zzo38computer
I think that you can, as long as the entire project as a whole, when
distributed, is licensed by GPL, even if all of your own source files use MIT
license. (Since it is compatible, it can be done.) If you later remove CGAL
then you do not need GPL, I think, and can distribute the version without CGAL
as MIT license. (However, I am not a copyright lawyer so I don't know, but I
think this is correct.)

~~~
huxingyi
Thanks, that's good!

------
bristleworm
This depends on the exact license they chose.
[https://www.cgal.org/license.html](https://www.cgal.org/license.html) states
that they use both GPLv3+ and LGPL. And they even offer a commercial license.
I'd contact them and ask just to be sure. There's a mail address in the third
paragraph.

~~~
huxingyi
Thanks, I mainly use the CGAL/Polygon_mesh_processing to do mesh boolean. I
saw some thread say CGAL commercial license cost $12K, it's not affordable for
a side project yet.

------
saluki
Take a look at this if you haven't already.
[https://stackoverflow.com/questions/9349220/2d-geometry-
libr...](https://stackoverflow.com/questions/9349220/2d-geometry-library-lgpl-
alternative-to-cgal)

~~~
huxingyi
Thanks, I checked that link. The "CGAL/Polygon Mesh Processing" package is
licensed on GPL:
[https://doc.cgal.org/latest/Manual/packages.html](https://doc.cgal.org/latest/Manual/packages.html)

And the mentioned other libraries doesn't have the features I want.

