I must use the C++ OpenVPN3 library to develop a Qt application with OpenVPN capabilities. The problem is that I need to make a class that derives from both QObject and an abstract class provided by this library.
class Client : public QObject, public ClientAPI::OpenVPNClient {
Q_OBJECT
{
. . .
}
All of the types I need to use are kept in one big source (cpp) file called ovpncli.cpp
. This becomes problematic when I'm now including a source file in a header file, because it causes a multiple definition error when the translation units are generated by the compiler. Classes that inherit from QObject must also have a separate definition and implementation unless you add "include myclass.moc" to the end (but this hasn't worked for me as seen here). The library developers have not said much other than "putting the OpenVPN header files only in my class's implementation file", but this is impossible because the class definition is inheriting from a class defined only in the `ovpnfile.
Is there a way I can include a cpp file in a header file while preventing the multiple definition error at the same time?