I have developed and released an open-source Java library under Apache 2.0 license. In the next version, I plan to include BerkeleyDB as one of the supported storage engines. Note that the actual BerkeleyDB source and binaries will not be included in my release. I use a Maven structure, so BerkeleyDB will be declaired as one of the dependencies.

Unfortunately BerkeleyDB is licensed under AGPLv3 and as far as I know it is not compatible with Apache 2. My question is does this affect the license of my software? I want to continue allowing the users to use my lib in commercial applications. Does adding BerkeleyDB support effectively forces them to open-source their projects IF they use my library?

2 Answers 2


The FSF insists that linking against a GPL library makes the result a derivative, and thus must be under GPL. That is not what the relevant law says (it is silent on "linking"). On the other hand, to use the library you need the declarations of the stuff in it, which is in a header file included in the source. Thus it does depend on a piece of the library... and again, if that is enough to make it a derivative isn't clear cut.

  • Linking to the header files is also considered using the source?!? I had in mind of declaring the dependency optional and forcing the user to explicitly declare the dependency on his project if we wants to use BerkeleyDB. From your answer it seems that even writing code that could be used as a bridge between my library and BerkeleyDB can cause issues. What if I split this to a separate module and not include it in the main lib? I should be safe then right? Commented Jan 21, 2016 at 14:00
  • You #include them. You have to write against the API exposed by the library, what you write depends on the library, even if you never read a line of it.
    – vonbrand
    Commented Jan 21, 2016 at 21:07
  • 1
    GPL (and AGPL) specifically spells out that if you use it, you must GPL/AGPL anything you make that depends on it. (So I guess you could make it a dependency, it's just now illegal for anyone to actually use the software; they can only look at it. (Also, you're in trouble if you ever downloaded BerkeleyDB, since you agreed to the GPL when you downloaded it.) Commented Jan 24, 2016 at 2:08

Yeah, many insist that this linking will form a derivative work. Even if this notion isn't shared by law courts (and this wasn't really tested in court as far as i know), many people might avoid your library because they claim the licensing isn't in order (if you use Apache and linking a AGPL3 library).

That usually means you should release your library also under AGPL3.

There is a way to avoid it: not linking permanent. If your software compiles and works without Berkeley DB and you don't distribute Berkeley DB with your binaries or software you might use Apache. You let the user form the derivative work if needed, for instance by including a switch that - if activated - includes Berkeley DB but is disabled as default.

If you want to always use Berkeley though, you have to accept their license terms.

NOTE: Look into discussion, especially @vonbrands comment to see a different legal view.

  • What if I add a storage engine for BerkeleyDB in the main software but declare the dependency optional? This way, I don't distribute their software and the user must explicitly define BerkeleyDB as dependency in his project to use it. You think I'm covered? Commented Jan 21, 2016 at 13:51
  • Won't cut it, "just add a switch" means the code directly dependent on BerkeleyDB is in your source code. Even distributing a patch for adding it in could be taken as code dependent on it.
    – vonbrand
    Commented Jan 21, 2016 at 21:09
  • @vonbrand: That won't be enough? In my understanding the switch means you can build it without the GPL-library, hence it isn't a derivative work (as long as you do not deliver binaries with the activated Berkeley DB). And for the patch I think the patch would be GPL (as it clearly depends on Berkeley) but not the software as long as it doesn't include the patch. Am I wrong here?
    – Mnementh
    Commented Jan 22, 2016 at 13:23
  • @Mnementh, in the source you'll have the code activated by the switch, and that creates the dependency. Probably even if it is disabled completely.
    – vonbrand
    Commented Jan 22, 2016 at 13:27
  • @Mnementh Indeed, even commented out would still count, since you have code that depends on it. Commented Jan 24, 2016 at 2:05

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.