Search code examples
c++visual-c++dllstatic-linkingbuild-tools

C++ DLL: Inheritance and usage of a class defined in a static library


I'm trying to build a DLL, which implements a class that inherent from a class inside a precompiled static library.

The both projects have a shared header file where the first class is declared (GroovyClass.h):

class GroovyClass
{
public:
    GroovyClass();
    virtual ~GroovyClass();
}

In the static lib this class is defined and implemented (GroovyClass.cpp) and compiled (let's call the result GroovyClass.lib).

In the shared library/DLL this class is then inherited like this:

#include "GroovyClass.h"

class MassiveFail : GroovyClass
{
public:
    MassiveFail();
    virtual ~MassiveFail();
}

This compiles, but at the linking stage I get errors regarding unresolved symbols for the GroovyClass constructor and destructor. I link with GroovyClass.lib as usual, so I don't understand why it can't find the symbols.

Do I need to declare GroovyClass in some special way before being able to use/inherit it in my DLL project?


Solution

  • Code and implementation was correct from the start!

    The actual problem and solution: The build system I was using (bam) used different "input tables" when building static libraries versus shared libraries.

    So for future users of bam; use the table settings.dll instead of settings.link if you are building and linking a DLL.