So I have a base class called RequestChannel and I have another class that is derived from it called FIFORequestChannel. I also have a file called trial.cpp where I have my main. I therefore have following files:
RequestChannel.h
FIFORequestChannel.h (includes RequestChannel.h)
FIFORequestChannel.cpp (includes FIFORequestChannel.h)
trial.cpp (includes FIFORequestChannel.h)
I didn't see the point of having .cpp file for RequestChannel since it is just my base class and no implementation is provided. I have made the following makefile to compile it:
all: trial
FIFORequestChannel.o: FIFORequestChannel.h RequestChannel.h FIFORequestChannel.cpp
    g++ -g -w -Wall -O1 -std=c++11 -c FIFORequestChannel.cpp 
trial: trial.cpp FIFORequestChannel.o  
    g++ -g -w -Wall -O1 -std=c++11 -o trial trial.cpp FIFORequestChannel.o -lpthread
clean:
    rm -rf *.o  trial
My problem is that I am trying to create a makefile for it but I keep getting the following error:
Undefined symbols for architecture x86_64:
  "typeinfo for RequestChannel", referenced from:
      typeinfo for FIFORequestChannel in FIFORequestChannel.o
  "vtable for RequestChannel", referenced from:
      RequestChannel::RequestChannel() in FIFORequestChannel.o
      RequestChannel::~RequestChannel() in FIFORequestChannel.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [trial] Error 1
I don't know if I am also supposed to include RequestChannel.h in FIFOFIFORequestChannel.cpp even though it is already included in FIFOFIFORequestChannel.h already
Here is the code:
RequestChannel.h
class RequestChannel {
public:
 RequestChannel(){};
 ~RequestChannel(){};
 virtual int cwrite (string)= 0;
 virtual string cread ();
};
FIFORequestChannel.h
#include "RequestChannel.h"
using namespace std;
class FIFORequestChannel: public RequestChannel {
private:
public:
   FIFORequestChannel();
  ~FIFORequestChannel();
   int cwrite (string);
   string cread();
};
FIFORequestChannel.cpp
#include "FIFORequestChannel.h"
using namespace std;
FIFORequestChannel::FIFORequestChannel(){
    cout << "Constructor worked" <<endl;
}
FIFORequestChannel::~FIFORequestChannel(){
    cout << "Destructor worked" <<endl;
}
int FIFORequestChannel::cwrite (string){
    cout << "cwrite() inside of derived class" << endl;
}
string FIFORequestChannel::cread(){
    cout << "cread() inside of derived class" << endl;
}
trial.cpp
#include <iostream>
#include "FIFORequestChannel.h"
using namespace std;
int main(){
    RequestChannel* rq = new FIFORequestChannel();
    return 0;
}
 
     
    