Unable to inherit from ButtonListener : Vtable error in Xcode

Hello,

I try to make my class inheriting  ButtonListener but the linker always return this error:

Undefined symbols for architecture i386:
  "vtable for DrumStripeHandler", referenced from:
      DrumStripeHandler::DrumStripeHandler(JuceDemoPluginAudioProcessorEditor*, juce::DirectoryContentsList*, juce::String, int) in DrumStripeHandler.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

According to docs, the buttonClicked is the ony pure virtual method for ButtonListener, so just implementing it should be enough, but it fails.

My class works well as soon I remove ButtonListener inheritence and the associated methods.
 

Header file:

class DrumStripeHandler:  public ButtonListener 

...
public:
    void buttonClicked (Button* )  override;
    void buttonStateChanged(Button *) override;

CPP file:

void DrumStripeHandler::buttonClicked(Button *button){
    
}

void DrumStripeHandler::buttonStateChanged(Button *button){
    
}

Sorry to bother you with such a simple question but I spent hours on it and can't find the problem... :/

Thanks

Could you show the rest of your header? I've seen things like this happen when there's a virtual destructor with no implementation. Also, the error seems to be referencing a constructor, so that code would be helpful.

Any other information that might be relevant is good too.

Solved... I forgot to implement the destructor in the cpp... Sorry for the waste of time and thanks for your answer, it helped =)

1 Like