0

I have the class DvQkdLdpcTxMessageProcessorReceiver as follow:

#ifndef DV_QKD_LDPC_TX_MESSAGE_PROCESSOR_RECEIVER_H_
#define DV_QKD_LDPC_TX_MESSAGE_PROCESSOR_RECEIVER_H_

#include "netxpto_20200819.h"
#include "dv_qkd_message_processor_common_20200819.h"

class DvQkdLdpcTxMessageProcessorReceiver : public Block 
{
public:
    DvQkdLdpcTxMessageProcessorReceiver(std::initializer_list<Signal*> InputSig, std::initializer_list<Signal*> OutputSig) : Block(InputSig, OutputSig) {};

    void initialize(void);

    bool runBlock(void);

private:
    
    // Input Parameters ##################################################################################

    // State Variables ###################################################################################

    std::vector<t_message> storedMessages{};
    
    // Basis Reconciliation
    t_integer messageReconciliationMaximumDataLength{ 4096 };
    CircularBuffer<t_binary> BasesFrom{ messageReconciliationMaximumDataLength };

    // Parameter Estimation
    t_integer messageParameterEstimationMaximumDataLength{ 100 };

    t_integer numberOfProcessedBits{ -1 };

    CircularBuffer<t_integer> SeedFrom{ 10 };
    CircularBuffer<t_integer> RatioFrom{ 10 };
    CircularBuffer<t_integer> NumberOfBitsPerEstimationBlockFrom{ 10 };
    CircularBuffer<t_binary> DataFrom{ 10*(size_t) messageParameterEstimationMaximumDataLength };

    // Error correction - Parities
    std::vector<t_integer> parityIn{};
    bool errCorrParitiesStarted{ false };

    // Sindrome
    t_integer messageSindromeMaximumDataLength{ 5000 };
    CircularBuffer<t_binary> Sindrome{ messageSindromeMaximumDataLength };

    // Error correction - Permutations
    std::vector<t_integer> permutationsIn{};
    bool errCorrPermStarted{ false };

    // Error correction - BER
    std::vector<t_integer> errCorrBerIn{};
    bool errCorrBerStarted{ false };

    // Privacy amplification seeds
    std::vector<t_integer> privacySeedsIn{};
    bool privacySeedsStarted{ false };

    bool outputReceivedData(std::vector <t_integer>& dataVector, Signal& outputSignal, bool &started);

};
#endif // !MESSAGE_PROCESSOR_RECEIVER_H_

The parent class is defined as:

class Block {

public:

    /* Methods */
    Block(){};
    Block(std::vector<Signal*> &InputSig, std::vector<Signal*> &OutputSig);
    Block(std::initializer_list<Signal*> InputSig, std::initializer_list<Signal*> OutputSig); // since C++11


    //void initializeBlock(std::vector<Signal*> InputSig, vector<Signal*> OutputSig);
    void initializeBlock();

    virtual void initialize(void) {};
    //bool runBlock();
    virtual bool runBlock();

    void terminateBlock();
    virtual void terminate(void) {};

    void closeOutputSignals();

    void setNumberOfInputSignals(int nOfInputSignal) { numberOfInputSignals = nOfInputSignal; };
    int getNumberOfInputSignals() { return numberOfInputSignals; };

    void setNumberOfOutputSignals(int nOfOutputSignal) { numberOfOutputSignals = nOfOutputSignal; };
    int getNumberOfOutputSignals() { return numberOfOutputSignals; };

    void setLogValue(bool lValue) { logValue = lValue; }
    bool getLogValue() { return logValue; }

    void setFirstRun(bool fRun) { firstRun = fRun; }
    bool getFirstRun() { return firstRun; }

    void setFirstTime(bool fTime) { firstTime = fTime; }
    bool getFirstTime() { return firstTime; }

    void setTerminated(bool t) { terminated = t; }
    bool getTerminated() { return terminated; }

    std::string getSignalsFolderName();

    void setVerboseMode(t_bool vMode) { verboseMode = vMode; }
    t_bool getVerboseMode(void) { return verboseMode; }

    void setVerboseFolderName(t_string vFolderName) { verboseFolderName = vFolderName; }
    t_string getVerboseFolderName(void) const { return verboseFolderName; }

    std::vector<Signal *> inputSignals;
    std::vector<Signal *> outputSignals;

private:

    bool logValue{ true };
    bool firstRun{ true };      // To be deleted, 2020/02/04, the name firstTime is more comum
    bool firstTime{ true };
    bool terminated{ false };

    t_bool verboseMode{ true };

    int numberOfInputSignals{ 1 };  
    int numberOfOutputSignals{ 1 }; 

    t_string verboseFolderName{ "verbose" };

};

when I make in the terminal, I receive the following error:

undefined reference to `vtable for DvQkdLdpcTxMessageProcessorReceiver'

enter image description here

How could I fix it? I searched a lot about the error (I tried to find pure virtual method or inline functions and ...), but no result. Thank you.

east1000
  • 1,240
  • 1
  • 10
  • 30
Zeinab Rahmani
  • 77
  • 3
  • 10
  • Give `DvQkdLdpcTxMessageProcessorReceiver` at least one `virtual` function. E.g. `~DvQkdLdpcTxMessageProcessorReceiver() = default;` – m88 Sep 08 '21 at 15:14
  • 2
    Does this answer your question? [Undefined reference to vtable](https://stackoverflow.com/questions/3065154/undefined-reference-to-vtable) – ShadowMitia Sep 08 '21 at 15:14
  • @ShadowMitia I studied this link and applied all the changes that were clear to me. but still receiving the same error. – Zeinab Rahmani Sep 08 '21 at 15:17
  • @ZeinabRahmani What changes did you make? – ShadowMitia Sep 08 '21 at 15:17
  • 2
    Please post all code and errors **as text** in the question. Please read [How to Ask](https://stackoverflow.com/questions/how-to-ask) with a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). – Ghasem Ramezani Sep 08 '21 at 15:18
  • @ShadowMitia For pure virtual method i did the following changes in the parent class: 1. bool runBlock(); virtual bool runBlock(){}; 2. virtual bool runBlock(void){}; 3. virtual bool runBlock(bool){return false;}; – Zeinab Rahmani Sep 08 '21 at 15:21
  • You don't have pure virtual functions. It seems you need to refresh your knowledge by using some of basic C++ books. – 273K Sep 08 '21 at 15:22
  • If looks like you don't link with block.o. – 273K Sep 08 '21 at 15:27
  • @S.M. Yes, I don't have a background and I am trying to improve my knowledge. But C++ is so vast. – Zeinab Rahmani Sep 08 '21 at 15:29
  • @S.M. Could you please explain with more detail about "If looks like you don't link with block.o"? thanx. – Zeinab Rahmani Sep 08 '21 at 15:31
  • @m88 I added `~DvQkdLdpcTxMessageProcessorReceiver() = default;` to the public section of the `class DvQkdLdpcTxMessageProcessorReceiver`, but nothing happened. Thanx. – Zeinab Rahmani Sep 08 '21 at 15:45
  • Where do you define `DvQkdLdpcTxMessageProcessorReceiver::initialize`? You've declared it in the header (an override of the virtual function in `Block`) but don't show a definition. – 1201ProgramAlarm Sep 08 '21 at 15:58
  • @1201ProgramAlarm It is in a .cpp file related to DvQkdLdpcTxMessageProcessorReceiver which is as follows: `void DvQkdLdpcTxMessageProcessorReceiver::initialize(void) { Sindrome.resize(outputSignals[5]->getBufferLength()); }`. If necessary, I can add this file, but it is a bit long. – Zeinab Rahmani Sep 08 '21 at 16:22

0 Answers0