Context
Suppose I have two projects called:
- Foo
- Bar
Goal: The Foo compiles to some sort of dynamic linking library such as a windows .dll and links to project Bar dynamically. And some of the headers files of the Foo project are included in the Bar project. And the Bar project links to the Foo project dynamically for getting the declarations. Below is a more detailed explanation.
Project Foo contains the following two files:
Interface.hpp:
#pragma once
#ifdef __WINDOWS__
#ifdef BUILD_DLL
#define API __declspec(dllexport)
#else
#define API __declspec(dllimport)
#endif
#else
#error only supports Windows!
#endif
#include <iostream>
#include <string>
class API Foo {
public:
Foo();
~Foo();
void greet(std::string name);
};
Implementation.cpp:
#include "Interface.hpp"
void Foo::greet(std::string name) {
std::cout << "Hello" + name << std::endl;
return;
}
And the Bar Project contains a main.cpp file with the following:
#include "Interface.hpp"
int main(int argc, char* argv[]) {
Foo instance = Foo();
instance.greet("Nasir");
return 0;
}
What I'm Asking
I would like to understand if this project setup complies with the GNU General Public License (GPL). Specifically, I am seeking clarification on whether project Bar, being proprietary and dynamically linking to project Foo while including the interface file (Interface.h) for function definitions, adheres to the requirements imposed by the GPL. If it doesn't adhere to the requirements imposed by the GPL, give me some guidance and resources or point-out what I am doing wrong and what I can do for a similar result.
Note: I am aware of the implications and restrictions imposed by the GPL when combining GPL-covered code with proprietary software. However, I am uncertain about the compliance aspect in the described scenario. I would greatly appreciate insights and guidance on ensuring compliance with the GPL within this context, considering the utilization of a controlled interface and dynamic linking between the Bar project (proprietary module) and the GPL-covered Foo project (library).
What did I try and what I’m expecting?
I Have Done My Research
I have read this article. And this is my main source of confusion.
I Have Produced the Confusion
To ensure compliance with the GNU General Public License (GPL), I have utilized a controlled interface approach, where Foo provides an API (defined in Interface.hpp) that is explicitly declared as either dllexport or dllimport based on the build configuration. The Bar project includes Interface.hpp for accessing the function definitions.
What Solution I’m Expecting
My expectation was to clarify whether this project setup adheres to the requirements of the GPL. I am aware of the restrictions and implications of the GPL when combining GPL-covered code with proprietary software. However, I seek guidance and insights regarding the compliance aspect in this particular scenario. Specifically, I would like to understand if the dynamic linking of the proprietary Bar project with the GPL-covered Foo project, while including the interface file (Interface.hpp) for function definitions, complies with the GPL.
If this project setup does not conform to the requirements imposed by the GPL, I would appreciate guidance, resources, or suggestions on what steps I can take to achieve a similar result while ensuring compliance with the GPL.