This is a vague idea I got recently and will try to work through as I’m writing this post. I got the idea in the first place is because I’ve been severely dissapointed by open source in the last few months (I’m ok now); and as the GPL fanatics are the worse of the open source crowd – I concentrated my anger on them. That’ll teach them not to piss me off again.

There are 2 flavours of GPL – the GPL and the LGPL. Each can be applied to libraries.

One is allowed to link to an LGPLed library and not release his own source code. One is not allowed to do that with GPLed libraries. If you link your program to a GPLed library you have to make your program open source. This is really annoying sometimes. For example if you use the free version of the QT widget toolkit your program must be GPLed. Not just open-sourced, mind you, but licenced under the same GPL version as the library you’re using.

I think I found a way around that. Let’s look at the original scenario first. Your program wants to use function doSomethingUseful() from UsefulLibrary. You include UsefulLibrary.h in SecretProgram.c to get the prototypes of the functions. So far the GPL probably has no effect, the header files are usually not covered by the GPL, but it doesn’t matter.

Because in the next step you link your program (cc SecretProgram.o UsefulLibrary.o -o SecretProgram) to the library. And this is where the GPL forces you to make your program open source. Even though you haven’t modified the GPLed code.

how the gpl works

But fear not! Andrew to the rescue! I will solve your problem with the mesed up interpretation of the licence as applying to software that isn’t already under that licence.

I give you a program (the binary is called gqfu). You tell it what functions you want to use from what library, and run it. GQFU will:

  1. Parse the header file and figure out what type of parameters the functions take and what the return type is.
  2. Automatically generate a main() that will take parameters from STDIN, convert them to the proper type, and call the appropriate function in UsefulLibrary.o
  3. For each function X() create a function gqfuX(), taking the same parameters and giving the same return type.
  4. Automatically generate (using some easy built-in logic) code for each gqfuX() function. This code will convert the parameters into an ASCII format, run the gqfuUsefulLibrary program, pipe some STDIN to it and get the result via STDOUT.
  5. Put all the gqfu*() implementations in gqfuUsefulLibrary.h

Once all that is done you build the generated gqfuUsefulLibrary.c and link it to UsefulLibrary. This will create a standalone binary application. The application will act something like a web services provider, except working via STDIO and no bloody XML.

The other half of the generated code (this will sit, for the sake of argument, in gqfuUsefulLibrary.h) will be included in, and built with SecretProgram.c. This part is like a web services requester.

how gqfu works

And guess what? You compile and link your SecretProgram.c without touching anything in UsefulLibrary – not even the header file. If you’re really paranoid, you don’t even have to use UsefulLibrary.h for automatically generating gqfuUsefulLibrary.h. You can just give the desired function prototypes to the gqfu program.

So there you go. Using a quick and easy tool you will avoid ridiculous GPL requirements that would otherwise force you to licence your program under the GPL.

Feel free to steal this idea and implement gqfu. You should even be able to make a business out of it. I bet there are lots of useful libraries that businesses would like to use if only not for the GPL. They would pay good money to avoid rewriting the functionality in those libraries.

I would do it myself, but it doesn’t look like I’m going to have any energy to spare for another project in the near future.